Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2022-12-03 07:52:16
Exec Total Coverage
Lines: 1304 3882 33.6%
Functions: 111 335 33.1%
Branches: 590 2734 21.6%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 9 #include "zc_sys.h"
17
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35
36 #ifdef ALLEGRO_DOS
37 #include <unistd.h>
38 #endif
39
40 #include "metadata/metadata.h"
41 #include "zelda.h"
42 #include "tiles.h"
43 #include "base/colors.h"
44 #include "pal.h"
45 #include "base/zsys.h"
46 #include "qst.h"
47 #include "zc_sys.h"
48 #include "play_midi.h"
49 #include "debug.h"
50 #include "jwin.h"
51 #include "base/jwinfsel.h"
52 #include "base/gui.h"
53 #include "midi.h"
54 #include "subscr.h"
55 #include "maps.h"
56 #include "sprite.h"
57 #include "guys.h"
58 #include "hero.h"
59 #include "title.h"
60 #include "particles.h"
61 #include "zconsole.h"
62 #include "ffscript.h"
63 #include "dialog/info.h"
64 #include "dialog/alert.h"
65 #include <fmt/format.h>
66
67 #ifdef __EMSCRIPTEN__
68 #include "base/emscripten_utils.h"
69 #endif
70
71 extern FFScript FFCore;
72 extern bool Playing;
73 int32_t sfx_voice[WAV_COUNT];
74 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
75 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
76
77 extern byte monochrome_console;
78
79 extern FONT *lfont;
80 extern HeroClass Hero;
81 extern FFScript FFCore;
82 extern ZModule zcm;
83 extern zcmodule moduledata;
84 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
85 extern particle_list particles;
86 extern int32_t loadlast;
87 extern word passive_subscreen_doscript;
88 extern bool passive_subscreen_waitdraw;
89 byte disable_direct_updating;
90 byte use_dwm_flush;
91 byte use_save_indicator;
92 byte midi_patch_fix;
93 bool midi_paused=false;
94 int32_t paused_midi_pos = 0;
95 byte midi_suspended = 0;
96 byte callback_switchin = 0;
97 byte zc_192b163_warp_compatibility;
98 char modulepath[2048];
99 byte epilepsyFlashReduction;
100 signed char pause_in_background_menu_init = 0;
101
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
9 byte pause_in_background = 0;
102 bool is_sys_pal = false;
103 extern PALETTE* hw_palette;
104 extern bool update_hw_pal;
105 extern const char* dmaplist(int32_t index, int32_t* list_size);
106
107
108 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
109 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
110 //extern byte refresh_select_screen;
111 //extern movingblock mblock2; //mblock[4]?
112 //extern int32_t db;
113
114 static const char *ZC_str = "Zelda Classic";
115 extern char save_file_name[1024];
116 #ifdef ALLEGRO_DOS
117 const char *qst_dir_name = "dos_qst_dir";
118 #elif defined(ALLEGRO_WINDOWS)
119 const char *qst_dir_name = "win_qst_dir";
120 static const char *qst_module_name = "current_module";
121 #elif defined(ALLEGRO_LINUX)
122 const char *qst_dir_name = "linux_qst_dir";
123 static const char *qst_module_name = "current_module";
124 #elif defined(__APPLE__)
125 const char *qst_dir_name = "osx_qst_dir";
126 static const char *qst_module_name = "current_module";
127 #endif
128 #ifdef ALLEGRO_LINUX
129 static const char *samplepath = "samplesoundset/patches.dat";
130 #endif
131 char qst_files_path[2048];
132
133 #ifdef _MSC_VER
134 #define getcwd _getcwd
135 #endif
136
137 bool rF11();
138 bool rI();
139 bool rQ();
140 bool zc_key_pressed();
141
142 #ifdef _WIN32
143
144 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
145 extern "C"
146 {
147 typedef HRESULT(WINAPI *t_DwmFlush)();
148 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
149 }
150
151 void do_DwmFlush()
152 {
153 static HMODULE shell = LoadLibrary("dwmapi.dll");
154
155 if(!shell)
156 return;
157
158 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
159 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
160
161 BOOL enabled;
162 isEnabled(&enabled);
163
164 if(isEnabled)
165 flush();
166 }
167
168 #endif // _WIN32
169
170 // Dialogue largening
171 void large_dialog(DIALOG *d)
172 {
173 large_dialog(d, 1.5);
174 }
175
176 void large_dialog(DIALOG *d, float RESIZE_AMT)
177 {
178 if(!d[0].d1)
179 {
180 d[0].d1 = 1;
181 int32_t oldwidth = d[0].w;
182 int32_t oldheight = d[0].h;
183 int32_t oldx = d[0].x;
184 int32_t oldy = d[0].y;
185 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
186 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
187 d[0].w = int32_t(d[0].w*RESIZE_AMT);
188 d[0].h = int32_t(d[0].h*RESIZE_AMT);
189
190 for(int32_t i=1; d[i].proc !=NULL; i++)
191 {
192 // Place elements horizontally
193 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
194 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
195
196 if(d[i].proc != d_stringloader)
197 {
198 if(d[i].proc==d_bitmap_proc)
199 {
200 d[i].w *= 2;
201 }
202 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
203 }
204
205 // Place elements vertically
206 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
207 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
208
209 // Vertically resize elements
210 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
211 {
212 d[i].h = int32_t((double)d[i].h*1.5);
213 }
214 else if(d[i].proc == jwin_droplist_proc)
215 {
216 d[i].y += int32_t((double)d[i].h*0.25);
217 d[i].h = int32_t((double)d[i].h*1.25);
218 }
219 else if(d[i].proc==d_bitmap_proc)
220 {
221 d[i].h *= 2;
222 }
223 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
224
225 // Fix frames
226 if(d[i].proc == jwin_frame_proc)
227 {
228 d[i].x++;
229 d[i].y++;
230 d[i].w-=4;
231 d[i].h-=4;
232 }
233 }
234 }
235
236 for(int32_t i=1; d[i].proc!=NULL; i++)
237 {
238 if(d[i].proc==jwin_slider_proc)
239 continue;
240
241 // Bigger font
242 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
243
244 if(!d[i].dp2 && bigfontproc)
245 {
246 //d[i].dp2 = (d[i].proc == jwin_edit_proc) ? sfont3 : lfont_l;
247 d[i].dp2 = lfont_l;
248 }
249 else if(!bigfontproc)
250 {
251 // ((ListData *)d[i].dp)->font = &sfont3;
252 ((ListData *)d[i].dp)->font = &lfont_l;
253 }
254
255 // Make checkboxes work
256 if(d[i].proc == jwin_check_proc)
257 d[i].proc = jwin_checkfont_proc;
258 else if(d[i].proc == jwin_radio_proc)
259 d[i].proc = jwin_radiofont_proc;
260 }
261
262 jwin_center_dialog(d);
263 }
264
265
266 /**********************************/
267 /******** System functions ********/
268 /**********************************/
269
270 static char cfg_sect[] = "zeldadx"; //We need to rename this.
271
272 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
273 {
274 return D_O_K;
275 }
276
277 9 void load_game_configs()
278 {
279 //set_config_file("zc.cfg"); //shift back when done
280 //load the module
281 9 strcpy(moduledata.module_name,get_config_string("ZCMODULE",qst_module_name,"classic.zmod"));
282 9 joystick_index = zc_get_config(cfg_sect,"joystick_index",0);
283 9 js_stick_1_x_stick = zc_get_config(cfg_sect,"js_stick_1_x_stick",0);
284 9 js_stick_1_x_axis = zc_get_config(cfg_sect,"js_stick_1_x_axis",0);
285 9 js_stick_1_x_offset = zc_get_config(cfg_sect,"js_stick_1_x_offset",0) ? 128 : 0;
286 9 js_stick_1_y_stick = zc_get_config(cfg_sect,"js_stick_1_y_stick",0);
287 9 js_stick_1_y_axis = zc_get_config(cfg_sect,"js_stick_1_y_axis",1);
288 9 js_stick_1_y_offset = zc_get_config(cfg_sect,"js_stick_1_y_offset",0) ? 128 : 0;
289 9 js_stick_2_x_stick = zc_get_config(cfg_sect,"js_stick_2_x_stick",1);
290 9 js_stick_2_x_axis = zc_get_config(cfg_sect,"js_stick_2_x_axis",0);
291 9 js_stick_2_x_offset = zc_get_config(cfg_sect,"js_stick_2_x_offset",0) ? 128 : 0;
292 9 js_stick_2_y_stick = zc_get_config(cfg_sect,"js_stick_2_y_stick",1);
293 9 js_stick_2_y_axis = zc_get_config(cfg_sect,"js_stick_2_y_axis",1);
294 9 js_stick_2_y_offset = zc_get_config(cfg_sect,"js_stick_2_y_offset",0) ? 128 : 0;
295 9 analog_movement = (zc_get_config(cfg_sect,"analog_movement",1));
296
297 //cheat modifier keya
298 9 cheat_modifier_keys[0] = zc_get_config(cfg_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
299 9 cheat_modifier_keys[1] = zc_get_config(cfg_sect,"key_cheatmod_a2",0);
300 9 cheat_modifier_keys[2] = zc_get_config(cfg_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
301 9 cheat_modifier_keys[3] = zc_get_config(cfg_sect,"key_cheatmod_b2",0);
302
303
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
304 joystick_index = 0;
305
306 9 Akey = zc_get_config(cfg_sect,"key_a",KEY_Z);
307 9 Bkey = zc_get_config(cfg_sect,"key_b",KEY_X);
308 9 Skey = zc_get_config(cfg_sect,"key_s",KEY_ENTER);
309 9 Lkey = zc_get_config(cfg_sect,"key_l",KEY_Q);
310 9 Rkey = zc_get_config(cfg_sect,"key_r",KEY_W);
311 9 Pkey = zc_get_config(cfg_sect,"key_p",KEY_SPACE);
312 9 Exkey1 = zc_get_config(cfg_sect,"key_ex1",KEY_A);
313 9 Exkey2 = zc_get_config(cfg_sect,"key_ex2",KEY_S);
314 9 Exkey3 = zc_get_config(cfg_sect,"key_ex3",KEY_D);
315 9 Exkey4 = zc_get_config(cfg_sect,"key_ex4",KEY_C);
316
317 9 DUkey = zc_get_config(cfg_sect,"key_up", KEY_UP);
318 9 DDkey = zc_get_config(cfg_sect,"key_down", KEY_DOWN);
319 9 DLkey = zc_get_config(cfg_sect,"key_left", KEY_LEFT);
320 9 DRkey = zc_get_config(cfg_sect,"key_right",KEY_RIGHT);
321
322 9 Abtn = zc_get_config(cfg_sect,"btn_a",2);
323 9 Bbtn = zc_get_config(cfg_sect,"btn_b",1);
324 9 Sbtn = zc_get_config(cfg_sect,"btn_s",10);
325 9 Mbtn = zc_get_config(cfg_sect,"btn_m",9);
326 9 Lbtn = zc_get_config(cfg_sect,"btn_l",5);
327 9 Rbtn = zc_get_config(cfg_sect,"btn_r",6);
328 9 Pbtn = zc_get_config(cfg_sect,"btn_p",12);
329 9 Exbtn1 = zc_get_config(cfg_sect,"btn_ex1",7);
330 9 Exbtn2 = zc_get_config(cfg_sect,"btn_ex2",8);
331 9 Exbtn3 = zc_get_config(cfg_sect,"btn_ex3",4);
332 9 Exbtn4 = zc_get_config(cfg_sect,"btn_ex4",3);
333
334 9 DUbtn = zc_get_config(cfg_sect,"btn_up",13);
335 9 DDbtn = zc_get_config(cfg_sect,"btn_down",14);
336 9 DLbtn = zc_get_config(cfg_sect,"btn_left",15);
337 9 DRbtn = zc_get_config(cfg_sect,"btn_right",16);
338
339 9 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
340
341 9 digi_volume = zc_get_config(cfg_sect,"digi",248);
342 9 midi_volume = zc_get_config(cfg_sect,"midi",255);
343 9 sfx_volume = zc_get_config(cfg_sect,"sfx",248);
344 9 emusic_volume = zc_get_config(cfg_sect,"emusic",248);
345 9 pan_style = zc_get_config(cfg_sect,"pan",1);
346 // 1 <= zcmusic_bufsz <= 128
347 9 zcmusic_bufsz = vbound(zc_get_config(cfg_sect,"zcmusic_bufsz",64),1,128);
348 9 volkeys = zc_get_config(cfg_sect,"volkeys",0)!=0;
349 9 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
350 9 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
351 9 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
352 9 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
353 9 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
354 #ifdef __EMSCRIPTEN__
355 if (em_is_mobile()) NameEntryMode = 2;
356 #endif
357 9 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
358 9 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
359 9 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
360 9 title_version = zc_get_config(cfg_sect,"title",2);
361 9 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
362 9 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
363
364 //default - scale x2, 640 x 480
365 9 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
366 9 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
367 9 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
368 9 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
369 9 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
370
371 9 loadlast = zc_get_config(cfg_sect,"load_last",0);
372
373 9 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
374
375 9 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
376
377 //workaround for the 100% CPU bug. -Gleeok
378 #ifdef ALLEGRO_MACOSX //IIRC rest(0) was a mac issue fix.
379 9 frame_rest_suggest = (byte) zc_get_config(cfg_sect,"frame_rest_suggest",0);
380 #else
381 frame_rest_suggest = (byte) zc_get_config(cfg_sect,"frame_rest_suggest",1);
382 #endif
383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 frame_rest_suggest = zc_min(2, frame_rest_suggest);
384
385 9 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
386
387 #ifdef _WIN32
388 use_debug_console = (byte) zc_get_config(cfg_sect,"debug_console",0);
389 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
390 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
391 console_on_top = (byte) zc_get_config("CONSOLE","console_on_top",0);
392 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
393 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
394
395 // This seems to fix some problems on Windows 7
396 disable_direct_updating = (byte) zc_get_config("graphics","disable_direct_updating",1);
397
398 // This one's for Aero
399 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
400
401 // And this one fixes patches unloading on some MIDI setups
402 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
403 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
404 #else //UNIX
405 9 use_debug_console = false;//(byte) zc_get_config(cfg_sect,"debug_console",0);
406 9 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
407 9 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
408 9 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
409 #endif
410
411 9 char const* default_path = "";
412 9 strcpy(qstdir,get_config_string(cfg_sect,qst_dir_name,default_path));
413
414
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8 times.
9 if(strlen(qstdir)==0)
415 {
416 1 getcwd(qstdir,2048);
417 1 fix_filename_case(qstdir);
418 1 fix_filename_slashes(qstdir);
419 1 put_backslash(qstdir);
420 1 }
421 else
422 {
423 8 chop_path(qstdir);
424 }
425
426 9 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
427 9 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
428 9 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
429 9 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
430 9 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
431 9 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
432 9 gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
433 9 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
434 9 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
435 9 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
436 9 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
437 9 }
438
439 9 void save_game_configs()
440 {
441 9 packfile_password("");
442
443 9 set_config_string("ZCMODULE",qst_module_name,moduledata.module_name);
444
445 9 set_config_int(cfg_sect,"joystick_index",joystick_index);
446 9 set_config_int(cfg_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
447 9 set_config_int(cfg_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
448 9 set_config_int(cfg_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
449 9 set_config_int(cfg_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
450 9 set_config_int(cfg_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
451 9 set_config_int(cfg_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
452 9 set_config_int(cfg_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
453 9 set_config_int(cfg_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
454 9 set_config_int(cfg_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
455 9 set_config_int(cfg_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
456 9 set_config_int(cfg_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
457 9 set_config_int(cfg_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
458 9 set_config_int(cfg_sect,"analog_movement",analog_movement);
459
460 //cheat modifier keya
461
462 9 set_config_int(cfg_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
463 9 set_config_int(cfg_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
464 9 set_config_int(cfg_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
465 9 set_config_int(cfg_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
466
467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (!replay_is_replaying())
468 {
469 9 set_config_int(cfg_sect,"key_a",Akey);
470 9 set_config_int(cfg_sect,"key_b",Bkey);
471 9 set_config_int(cfg_sect,"key_s",Skey);
472 9 set_config_int(cfg_sect,"key_l",Lkey);
473 9 set_config_int(cfg_sect,"key_r",Rkey);
474 9 set_config_int(cfg_sect,"key_p",Pkey);
475 9 set_config_int(cfg_sect,"key_ex1",Exkey1);
476 9 set_config_int(cfg_sect,"key_ex2",Exkey2);
477 9 set_config_int(cfg_sect,"key_ex3",Exkey3);
478 9 set_config_int(cfg_sect,"key_ex4",Exkey4);
479 9 set_config_int(cfg_sect,"key_up", DUkey);
480 9 set_config_int(cfg_sect,"key_down", DDkey);
481 9 set_config_int(cfg_sect,"key_left", DLkey);
482 9 set_config_int(cfg_sect,"key_right",DRkey);
483 9 }
484
485 9 set_config_int(cfg_sect,"btn_a",Abtn);
486 9 set_config_int(cfg_sect,"btn_b",Bbtn);
487 9 set_config_int(cfg_sect,"btn_s",Sbtn);
488 9 set_config_int(cfg_sect,"btn_m",Mbtn);
489 9 set_config_int(cfg_sect,"btn_l",Lbtn);
490 9 set_config_int(cfg_sect,"btn_r",Rbtn);
491 9 set_config_int(cfg_sect,"btn_p",Pbtn);
492 9 set_config_int(cfg_sect,"btn_ex1",Exbtn1);
493 9 set_config_int(cfg_sect,"btn_ex2",Exbtn2);
494 9 set_config_int(cfg_sect,"btn_ex3",Exbtn3);
495 9 set_config_int(cfg_sect,"btn_ex4",Exbtn4);
496
497 9 set_config_int(cfg_sect,"btn_up",DUbtn);
498 9 set_config_int(cfg_sect,"btn_down",DDbtn);
499 9 set_config_int(cfg_sect,"btn_left",DLbtn);
500 9 set_config_int(cfg_sect,"btn_right",DRbtn);
501
502 9 set_config_int(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
503
504 9 set_config_int(cfg_sect,"digi",digi_volume);
505 9 set_config_int(cfg_sect,"midi",midi_volume);
506 9 set_config_int(cfg_sect,"sfx",sfx_volume);
507 9 set_config_int(cfg_sect,"emusic",emusic_volume);
508 9 set_config_int(cfg_sect,"pan",pan_style);
509 9 set_config_int(cfg_sect,"zcmusic_bufsz",zcmusic_bufsz);
510 9 set_config_int(cfg_sect,"volkeys",(int32_t)volkeys);
511 9 set_config_int(cfg_sect,"vsync",zc_vsync);
512 9 set_config_int(cfg_sect,"throttlefps", (int32_t)Throttlefps);
513 9 set_config_int(cfg_sect,"translayers",(int32_t)TransLayers);
514 9 set_config_int(cfg_sect,"snapshot_format",SnapshotFormat);
515 9 set_config_int(cfg_sect,"name_entry_mode",NameEntryMode);
516 9 set_config_int(cfg_sect,"showfps",(int32_t)ShowFPS);
517 9 set_config_int(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
518 9 set_config_int(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
519 9 set_config_int(cfg_sect,"drag_aspect",(int32_t)DragAspect);
520 9 set_config_int(cfg_sect,"fastquit",(int32_t)NESquit);
521 9 set_config_int(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
522 9 set_config_int(cfg_sect,"title",title_version);
523 //set_config_int(cfg_sect,"lister_pattern_matching",abc_patternmatch); //Enable once there is a GUI way to toggle this.
524
525
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
526 {
527 int o_window_x, o_window_y;
528 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
529 set_config_int(cfg_sect,"window_x",o_window_x);
530 set_config_int(cfg_sect,"window_y",o_window_y);
531 }
532
533
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
534 {
535 double monitor_scale = zc_get_monitor_scale();
536 window_width = al_get_display_width(all_get_display()) / monitor_scale;
537 window_height = al_get_display_height(all_get_display()) / monitor_scale;
538 set_config_int(cfg_sect,"window_width",window_width);
539 set_config_int(cfg_sect,"window_height",window_height);
540 }
541
542 9 set_config_int(cfg_sect,"load_last",loadlast);
543 9 chop_path(qstdir);
544 9 set_config_string(cfg_sect,qst_dir_name,qstdir);
545 9 set_config_string("SAVEFILE","save_filename",save_file_name);
546 9 set_config_int(cfg_sect,"ss_enable",ss_enable);
547 9 set_config_int(cfg_sect,"ss_after",ss_after);
548 9 set_config_int(cfg_sect,"ss_speed",ss_speed);
549 9 set_config_int(cfg_sect,"ss_density",ss_density);
550 9 set_config_int(cfg_sect,"heart_beep",heart_beep);
551 9 set_config_int(cfg_sect,"gui_colorset",gui_colorset);
552 9 set_config_int(cfg_sect,"use_sfx_dat",sfxdat);
553 9 set_config_int(cfg_sect,"fullscreen",fullscreen);
554 9 set_config_int(cfg_sect,"color_depth",zc_color_depth);
555 9 set_config_int(cfg_sect,"frame_rest_suggest",frame_rest_suggest);
556 9 set_config_int(cfg_sect,"force_exit",forceExit);
557
558 #ifdef _WIN32
559 set_config_int(cfg_sect,"debug_console",use_debug_console);
560 set_config_int("CONSOLE","print_ZASM",zasm_debugger);
561 set_config_int("CONSOLE","ZScript_Debugger",zscript_debugger);
562 set_config_int("CONSOLE","console_on_top",console_on_top);
563 //set_config_int(cfg_sect,"use_win7_key_fix",use_win7_keyboard_fix);
564 set_config_int(cfg_sect,"zc_win_proc_fix",use_win32_proc);
565 set_config_int("graphics","disable_direct_updating",disable_direct_updating);
566 set_config_int("zeldadx","use_dwm_flush",use_dwm_flush);
567 set_config_int("zeldadx","midi_patch_fix",midi_patch_fix);
568 set_config_int("CONSOLE","monochrome_debuggers",monochrome_console);
569 set_config_int("zeldadx","debug_console",zconsole);
570 #endif
571
572 #ifdef ALLEGRO_LINUX
573 set_config_string("sound","patches",samplepath); // set to sample sound path set for DIGMIDI driver in Linux ~ Takuya
574 #endif
575
576 9 set_config_int(cfg_sect,"save_indicator",use_save_indicator);
577 9 set_config_int(cfg_sect,"zc_192b163_warp_compatibility",zc_192b163_warp_compatibility);
578
579 9 flush_config_file();
580 #ifdef __EMSCRIPTEN__
581 em_sync_fs();
582 #endif
583 9 }
584
585 //----------------------------------------------------------------
586
587 // Timers
588
589 907 void fps_callback()
590 {
591 907 lastfps=framecnt;
592 907 dword tempsecs = fps_secs;
593 907 ++tempsecs;
594 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
595 907 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
596 907 ++fps_secs;
597 907 framecnt=0;
598 907 }
599
600 END_OF_FUNCTION(fps_callback)
601
602 9 int32_t Z_init_timers()
603 {
604 static bool didit = false;
605 const static char *err_str = "Couldn't allocate timer";
606 9 err_str = err_str; //Unused variable warning
607
608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(didit)
609 return 1;
610
611 9 didit = true;
612
613 LOCK_VARIABLE(lastfps);
614 LOCK_VARIABLE(framecnt);
615 LOCK_FUNCTION(fps_callback);
616
617
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
618 return 0;
619
620 9 return 1;
621 9 }
622
623 void Z_remove_timers()
624 {
625 remove_int(fps_callback);
626 }
627
628 //----------------------------------------------------------------
629
630 void go()
631 {
632 scare_mouse();
633 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
634 unscare_mouse();
635 }
636
637 void comeback()
638 {
639 scare_mouse();
640 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
641 unscare_mouse();
642 }
643
644 void dump_pal(BITMAP *dest)
645 {
646 for(int32_t i=0; i<256; i++)
647 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
648 }
649
650 //----------------------------------------------------------------
651
652 //Handles converting the mouse sprite from the .dat file
653 9 void load_mouse()
654 {
655 9 system_pal();
656 9 scare_mouse();
657 9 set_mouse_sprite(NULL);
658
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 int32_t sz = vbound(int32_t(16*(is_large ? get_config_float("zeldadx","cursor_scale_large",1.5) : get_config_float("zeldadx","cursor_scale_small",1))),16,80);
659
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 9 times.
45 for(int32_t j = 0; j < 4; ++j)
660 {
661 36 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
662 36 BITMAP* subbmp = create_bitmap_ex(8,16,16);
663
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(zcmouse[j])
664 destroy_bitmap(zcmouse[j]);
665 36 zcmouse[j] = create_bitmap_ex(8,sz,sz);
666 36 clear_bitmap(zcmouse[j]);
667 36 clear_bitmap(tmpbmp);
668 36 clear_bitmap(subbmp);
669 36 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
670
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 36 times.
612 for(int32_t x = 0; x < 16; ++x)
671 {
672
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 576 times.
9792 for(int32_t y = 0; y < 16; ++y)
673 {
674 9216 int32_t color = getpixel(tmpbmp, x, y);
675
5/5
✓ Branch 0 taken 8478 times.
✓ Branch 1 taken 171 times.
✓ Branch 2 taken 198 times.
✓ Branch 3 taken 207 times.
✓ Branch 4 taken 162 times.
9216 switch(color)
676 {
677 case dvc(1):
678 171 color = jwin_pal[jcCURSORMISC];
679 171 break;
680 case dvc(2):
681 198 color = jwin_pal[jcCURSOROUTLINE];
682 198 break;
683 case dvc(3):
684 207 color = jwin_pal[jcCURSORLIGHT];
685 207 break;
686 case dvc(5):
687 162 color = jwin_pal[jcCURSORDARK];
688 162 break;
689 }
690 9216 putpixel(subbmp, x, y, color);
691 9216 }
692 576 }
693
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(sz!=16)
694 36 stretch_blit(subbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
695 else
696 blit(subbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
697 36 destroy_bitmap(tmpbmp);
698 36 destroy_bitmap(subbmp);
699 36 }
700 9 set_mouse_sprite(zcmouse[0]);
701
702 // Must attempt to show cursor for allegro 5 to render it with the associated palette.
703 9 set_palette(*hw_palette);
704 9 show_mouse(screen);
705 9 show_mouse(NULL);
706
707 9 unscare_mouse();
708 9 game_pal();
709 9 }
710
711 // sets the video mode and initializes the palette and mouse sprite
712 9 bool game_vid_mode(int32_t mode,int32_t wait)
713 {
714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
715 {
716 return false;
717 }
718
719 9 scrx = (resx-320)>>1;
720 9 scry = (resy-240)>>1;
721
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 9 times.
45 for(int32_t q = 0; q < 4; ++q)
722 36 zcmouse[q] = NULL;
723 9 load_mouse();
724 9 set_mouse_sprite(zcmouse[0]);
725
726
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 9 times.
153 for(int32_t i=240; i<256; i++)
727 144 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
728
729 9 set_palette(RAMpal);
730 9 clear_to_color(screen,BLACK);
731
732 9 rest(wait);
733 9 return true;
734 9 }
735
736 void null_quest()
737 {
738 char qstdat_string[2048];
739 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
740 strcat(qstdat_string,"#NESQST_NEW_QST");
741
742 #ifdef __EMSCRIPTEN__
743 // The quest template data file is not included because it's really big and isn't really needed
744 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
745 // which is much smaller.
746 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
747 #endif
748
749 byte skip_flags[4] = { 0 };
750
751 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
752 }
753
754 void init_NES_mode()
755 {
756 /*
757 // qst.dat may not load correctly without this...
758 QHeader.templatepath[0]='\0';
759
760 if(!init_colordata(true, &QHeader, &QMisc))
761 {
762 return;
763 }
764
765 loadfullpal();
766 init_tiles(false, &QHeader);
767 */
768 null_quest();
769 }
770
771 //----------------------------------------------------------------
772
773 qword trianglelines[16]=
774 {
775 0x0000000000000000ULL,
776 0xFD00000000000000ULL,
777 0xFDFD000000000000ULL,
778 0xFDFDFD0000000000ULL,
779 0xFDFDFDFD00000000ULL,
780 0xFDFDFDFDFD000000ULL,
781 0xFDFDFDFDFDFD0000ULL,
782 0xFDFDFDFDFDFDFD00ULL,
783 0xFDFDFDFDFDFDFDFDULL,
784 0x00FDFDFDFDFDFDFDULL,
785 0x0000FDFDFDFDFDFDULL,
786 0x000000FDFDFDFDFDULL,
787 0x00000000FDFDFDFDULL,
788 0x0000000000FDFDFDULL,
789 0x000000000000FDFDULL,
790 0x00000000000000FDULL,
791 };
792
793 word screen_triangles[28][32];
794 /*
795 qword triangles[4][16]= //[direction][value]
796 {
797 {
798 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
799 },
800 {
801 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
802 },
803 {
804 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
805 },
806 {
807 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
808 }
809 };
810 */
811
812
813 /*
814 byte triangles[4][16][8]= //[direction][value][line]
815 {
816 {
817 {
818 0, 0, 0, 0, 0, 0, 0, 0
819 },
820 {
821 1, 0, 0, 0, 0, 0, 0, 0
822 },
823 {
824 2, 1, 0, 0, 0, 0, 0, 0
825 },
826 {
827 3, 2, 1, 0, 0, 0, 0, 0
828 },
829 {
830 4, 3, 2, 1, 0, 0, 0, 0
831 },
832 {
833 5, 4, 3, 2, 1, 0, 0, 0
834 },
835 {
836 6, 5, 4, 3, 2, 1, 0, 0
837 },
838 {
839 7, 6, 5, 4, 3, 2, 1, 0
840 },
841 {
842 8, 7, 6, 5, 4, 3, 2, 1
843 },
844 {
845 8, 8, 7, 6, 5, 4, 3, 2
846 },
847 {
848 8, 8, 8, 7, 6, 5, 4, 3
849 },
850 {
851 8, 8, 8, 8, 7, 6, 5, 4
852 },
853 {
854 8, 8, 8, 8, 8, 7, 6, 5
855 },
856 {
857 8, 8, 8, 8, 8, 8, 7, 6
858 },
859 {
860 8, 8, 8, 8, 8, 8, 8, 7
861 },
862 {
863 8, 8, 8, 8, 8, 8, 8, 8
864 }
865 },
866 {
867 {
868 0, 0, 0, 0, 0, 0, 0, 0
869 },
870 {
871 15, 0, 0, 0, 0, 0, 0, 0
872 },
873 {
874 14, 15, 0, 0, 0, 0, 0, 0
875 },
876 {
877 13, 14, 15, 0, 0, 0, 0, 0
878 },
879 {
880 12, 13, 14, 15, 0, 0, 0, 0
881 },
882 {
883 11, 12, 13, 14, 15, 0, 0, 0
884 },
885 {
886 10, 11, 12, 13, 14, 15, 0, 0
887 },
888 {
889 9, 10, 11, 12, 13, 14, 15, 0
890 },
891 {
892 8, 9, 10, 11, 12, 13, 14, 15
893 },
894 {
895 8, 8, 9, 10, 11, 12, 13, 14
896 },
897 {
898 8, 8, 8, 9, 10, 11, 12, 13
899 },
900 {
901 8, 8, 8, 8, 9, 10, 11, 12
902 },
903 {
904 8, 8, 8, 8, 8, 9, 10, 11
905 },
906 {
907 8, 8, 8, 8, 8, 8, 9, 10
908 },
909 {
910 8, 8, 8, 8, 8, 8, 8, 9
911 },
912 {
913 8, 8, 8, 8, 8, 8, 8, 8
914 }
915 },
916 {
917 {
918 0, 0, 0, 0, 0, 0, 0, 0
919 },
920 {
921 0, 0, 0, 0, 0, 0, 0, 1
922 },
923 {
924 0, 0, 0, 0, 0, 0, 1, 2
925 },
926 {
927 0, 0, 0, 0, 0, 1, 2, 3
928 },
929 {
930 0, 0, 0, 0, 1, 2, 3, 4
931 },
932 {
933 0, 0, 0, 1, 2, 3, 4, 5
934 },
935 {
936 0, 0, 1, 2, 3, 4, 5, 6
937 },
938 {
939 0, 1, 2, 3, 4, 5, 6, 7
940 },
941 {
942 1, 2, 3, 4, 5, 6, 7, 8
943 },
944 {
945 2, 3, 4, 5, 6, 7, 8, 8
946 },
947 {
948 3, 4, 5, 6, 7, 8, 8, 8
949 },
950 {
951 4, 5, 6, 7, 8, 8, 8, 8
952 },
953 {
954 5, 6, 7, 8, 8, 8, 8, 8
955 },
956 {
957 6, 7, 8, 8, 8, 8, 8, 8
958 },
959 {
960 7, 8, 8, 8, 8, 8, 8, 8
961 },
962 {
963 8, 8, 8, 8, 8, 8, 8, 8
964 }
965 },
966 {
967 {
968 0, 0, 0, 0, 0, 0, 0, 0
969 },
970 {
971 0, 0, 0, 0, 0, 0, 0, 15
972 },
973 {
974 0, 0, 0, 0, 0, 0, 15, 14
975 },
976 {
977 0, 0, 0, 0, 0, 15, 14, 13
978 },
979 {
980 0, 0, 0, 0, 15, 14, 13, 12
981 },
982 {
983 0, 0, 0, 15, 14, 13, 12, 11
984 },
985 {
986 0, 0, 15, 14, 13, 12, 11, 10
987 },
988 {
989 0, 15, 14, 13, 12, 11, 10, 9
990 },
991 {
992 15, 14, 13, 12, 11, 10, 9, 8
993 },
994 {
995 14, 13, 12, 11, 10, 9, 8, 8
996 },
997 {
998 13, 12, 11, 10, 9, 8, 8, 8
999 },
1000 {
1001 12, 11, 10, 9, 8, 8, 8, 8
1002 },
1003 {
1004 11, 10, 9, 8, 8, 8, 8, 8
1005 },
1006 {
1007 10, 9, 8, 8, 8, 8, 8, 8
1008 },
1009 {
1010 9, 8, 8, 8, 8, 8, 8, 8
1011 },
1012 {
1013 8, 8, 8, 8, 8, 8, 8, 8
1014 }
1015 }
1016 };
1017 */
1018
1019
1020
1021 /*
1022 for (int32_t blockrow=0; blockrow<30; ++i)
1023 {
1024 for (int32_t linerow=0; linerow<8; ++i)
1025 {
1026 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1027 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1028 {
1029 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1030 ++triangleline;
1031 }
1032 }
1033 }
1034 */
1035
1036 // the ULL suffixes are to prevent this warning:
1037 // warning: integer constant is too large for "int32_t" type
1038
1039 qword triangles[4][16][8]= //[direction][value][line]
1040 {
1041 {
1042 {
1043 0x0000000000000000ULL,
1044 0x0000000000000000ULL,
1045 0x0000000000000000ULL,
1046 0x0000000000000000ULL,
1047 0x0000000000000000ULL,
1048 0x0000000000000000ULL,
1049 0x0000000000000000ULL,
1050 0x0000000000000000ULL
1051 },
1052 {
1053 0xFD00000000000000ULL,
1054 0x0000000000000000ULL,
1055 0x0000000000000000ULL,
1056 0x0000000000000000ULL,
1057 0x0000000000000000ULL,
1058 0x0000000000000000ULL,
1059 0x0000000000000000ULL,
1060 0x0000000000000000ULL
1061 },
1062 {
1063 0xFDFD000000000000ULL,
1064 0xFD00000000000000ULL,
1065 0x0000000000000000ULL,
1066 0x0000000000000000ULL,
1067 0x0000000000000000ULL,
1068 0x0000000000000000ULL,
1069 0x0000000000000000ULL,
1070 0x0000000000000000ULL
1071 },
1072 {
1073 0xFDFDFD0000000000ULL,
1074 0xFDFD000000000000ULL,
1075 0xFD00000000000000ULL,
1076 0x0000000000000000ULL,
1077 0x0000000000000000ULL,
1078 0x0000000000000000ULL,
1079 0x0000000000000000ULL,
1080 0x0000000000000000ULL
1081 },
1082 {
1083 0xFDFDFDFD00000000ULL,
1084 0xFDFDFD0000000000ULL,
1085 0xFDFD000000000000ULL,
1086 0xFD00000000000000ULL,
1087 0x0000000000000000ULL,
1088 0x0000000000000000ULL,
1089 0x0000000000000000ULL,
1090 0x0000000000000000ULL
1091 },
1092 {
1093 0xFDFDFDFDFD000000ULL,
1094 0xFDFDFDFD00000000ULL,
1095 0xFDFDFD0000000000ULL,
1096 0xFDFD000000000000ULL,
1097 0xFD00000000000000ULL,
1098 0x0000000000000000ULL,
1099 0x0000000000000000ULL,
1100 0x0000000000000000ULL
1101 },
1102 {
1103 0xFDFDFDFDFDFD0000ULL,
1104 0xFDFDFDFDFD000000ULL,
1105 0xFDFDFDFD00000000ULL,
1106 0xFDFDFD0000000000ULL,
1107 0xFDFD000000000000ULL,
1108 0xFD00000000000000ULL,
1109 0x0000000000000000ULL,
1110 0x0000000000000000ULL
1111 },
1112 {
1113 0xFDFDFDFDFDFDFD00ULL,
1114 0xFDFDFDFDFDFD0000ULL,
1115 0xFDFDFDFDFD000000ULL,
1116 0xFDFDFDFD00000000ULL,
1117 0xFDFDFD0000000000ULL,
1118 0xFDFD000000000000ULL,
1119 0xFD00000000000000ULL,
1120 0x0000000000000000ULL
1121 },
1122 {
1123 0xFDFDFDFDFDFDFDFDULL,
1124 0xFDFDFDFDFDFDFD00ULL,
1125 0xFDFDFDFDFDFD0000ULL,
1126 0xFDFDFDFDFD000000ULL,
1127 0xFDFDFDFD00000000ULL,
1128 0xFDFDFD0000000000ULL,
1129 0xFDFD000000000000ULL,
1130 0xFD00000000000000ULL
1131 },
1132 {
1133 0xFDFDFDFDFDFDFDFDULL,
1134 0xFDFDFDFDFDFDFDFDULL,
1135 0xFDFDFDFDFDFDFD00ULL,
1136 0xFDFDFDFDFDFD0000ULL,
1137 0xFDFDFDFDFD000000ULL,
1138 0xFDFDFDFD00000000ULL,
1139 0xFDFDFD0000000000ULL,
1140 0xFDFD000000000000ULL
1141 },
1142 {
1143 0xFDFDFDFDFDFDFDFDULL,
1144 0xFDFDFDFDFDFDFDFDULL,
1145 0xFDFDFDFDFDFDFDFDULL,
1146 0xFDFDFDFDFDFDFD00ULL,
1147 0xFDFDFDFDFDFD0000ULL,
1148 0xFDFDFDFDFD000000ULL,
1149 0xFDFDFDFD00000000ULL,
1150 0xFDFDFD0000000000ULL
1151 },
1152 {
1153 0xFDFDFDFDFDFDFDFDULL,
1154 0xFDFDFDFDFDFDFDFDULL,
1155 0xFDFDFDFDFDFDFDFDULL,
1156 0xFDFDFDFDFDFDFDFDULL,
1157 0xFDFDFDFDFDFDFD00ULL,
1158 0xFDFDFDFDFDFD0000ULL,
1159 0xFDFDFDFDFD000000ULL,
1160 0xFDFDFDFD00000000ULL
1161 },
1162 {
1163 0xFDFDFDFDFDFDFDFDULL,
1164 0xFDFDFDFDFDFDFDFDULL,
1165 0xFDFDFDFDFDFDFDFDULL,
1166 0xFDFDFDFDFDFDFDFDULL,
1167 0xFDFDFDFDFDFDFDFDULL,
1168 0xFDFDFDFDFDFDFD00ULL,
1169 0xFDFDFDFDFDFD0000ULL,
1170 0xFDFDFDFDFD000000ULL
1171 },
1172 {
1173 0xFDFDFDFDFDFDFDFDULL,
1174 0xFDFDFDFDFDFDFDFDULL,
1175 0xFDFDFDFDFDFDFDFDULL,
1176 0xFDFDFDFDFDFDFDFDULL,
1177 0xFDFDFDFDFDFDFDFDULL,
1178 0xFDFDFDFDFDFDFDFDULL,
1179 0xFDFDFDFDFDFDFD00ULL,
1180 0xFDFDFDFDFDFD0000ULL
1181 },
1182 {
1183 0xFDFDFDFDFDFDFDFDULL,
1184 0xFDFDFDFDFDFDFDFDULL,
1185 0xFDFDFDFDFDFDFDFDULL,
1186 0xFDFDFDFDFDFDFDFDULL,
1187 0xFDFDFDFDFDFDFDFDULL,
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFD00ULL
1191 },
1192 {
1193 0xFDFDFDFDFDFDFDFDULL,
1194 0xFDFDFDFDFDFDFDFDULL,
1195 0xFDFDFDFDFDFDFDFDULL,
1196 0xFDFDFDFDFDFDFDFDULL,
1197 0xFDFDFDFDFDFDFDFDULL,
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL
1201 }
1202 },
1203 {
1204 {
1205 0x0000000000000000ULL,
1206 0x0000000000000000ULL,
1207 0x0000000000000000ULL,
1208 0x0000000000000000ULL,
1209 0x0000000000000000ULL,
1210 0x0000000000000000ULL,
1211 0x0000000000000000ULL,
1212 0x0000000000000000ULL
1213 },
1214 {
1215 0x00000000000000FDULL,
1216 0x0000000000000000ULL,
1217 0x0000000000000000ULL,
1218 0x0000000000000000ULL,
1219 0x0000000000000000ULL,
1220 0x0000000000000000ULL,
1221 0x0000000000000000ULL,
1222 0x0000000000000000ULL
1223 },
1224 {
1225 0x000000000000FDFDULL,
1226 0x00000000000000FDULL,
1227 0x0000000000000000ULL,
1228 0x0000000000000000ULL,
1229 0x0000000000000000ULL,
1230 0x0000000000000000ULL,
1231 0x0000000000000000ULL,
1232 0x0000000000000000ULL
1233 },
1234 {
1235 0x0000000000FDFDFDULL,
1236 0x000000000000FDFDULL,
1237 0x00000000000000FDULL,
1238 0x0000000000000000ULL,
1239 0x0000000000000000ULL,
1240 0x0000000000000000ULL,
1241 0x0000000000000000ULL,
1242 0x0000000000000000ULL
1243 },
1244 {
1245 0x00000000FDFDFDFDULL,
1246 0x0000000000FDFDFDULL,
1247 0x000000000000FDFDULL,
1248 0x00000000000000FDULL,
1249 0x0000000000000000ULL,
1250 0x0000000000000000ULL,
1251 0x0000000000000000ULL,
1252 0x0000000000000000ULL
1253 },
1254 {
1255 0x000000FDFDFDFDFDULL,
1256 0x00000000FDFDFDFDULL,
1257 0x0000000000FDFDFDULL,
1258 0x000000000000FDFDULL,
1259 0x00000000000000FDULL,
1260 0x0000000000000000ULL,
1261 0x0000000000000000ULL,
1262 0x0000000000000000ULL
1263 },
1264 {
1265 0x0000FDFDFDFDFDFDULL,
1266 0x000000FDFDFDFDFDULL,
1267 0x00000000FDFDFDFDULL,
1268 0x0000000000FDFDFDULL,
1269 0x000000000000FDFDULL,
1270 0x00000000000000FDULL,
1271 0x0000000000000000ULL,
1272 0x0000000000000000ULL
1273 },
1274 {
1275 0x00FDFDFDFDFDFDFDULL,
1276 0x0000FDFDFDFDFDFDULL,
1277 0x000000FDFDFDFDFDULL,
1278 0x00000000FDFDFDFDULL,
1279 0x0000000000FDFDFDULL,
1280 0x000000000000FDFDULL,
1281 0x00000000000000FDULL,
1282 0x0000000000000000ULL
1283 },
1284 {
1285 0xFDFDFDFDFDFDFDFDULL,
1286 0x00FDFDFDFDFDFDFDULL,
1287 0x0000FDFDFDFDFDFDULL,
1288 0x000000FDFDFDFDFDULL,
1289 0x00000000FDFDFDFDULL,
1290 0x0000000000FDFDFDULL,
1291 0x000000000000FDFDULL,
1292 0x00000000000000FDULL
1293 },
1294 {
1295 0xFDFDFDFDFDFDFDFDULL,
1296 0xFDFDFDFDFDFDFDFDULL,
1297 0x00FDFDFDFDFDFDFDULL,
1298 0x0000FDFDFDFDFDFDULL,
1299 0x000000FDFDFDFDFDULL,
1300 0x00000000FDFDFDFDULL,
1301 0x0000000000FDFDFDULL,
1302 0x000000000000FDFDULL
1303 },
1304 {
1305 0xFDFDFDFDFDFDFDFDULL,
1306 0xFDFDFDFDFDFDFDFDULL,
1307 0xFDFDFDFDFDFDFDFDULL,
1308 0x00FDFDFDFDFDFDFDULL,
1309 0x0000FDFDFDFDFDFDULL,
1310 0x000000FDFDFDFDFDULL,
1311 0x00000000FDFDFDFDULL,
1312 0x0000000000FDFDFDULL
1313 },
1314 {
1315 0xFDFDFDFDFDFDFDFDULL,
1316 0xFDFDFDFDFDFDFDFDULL,
1317 0xFDFDFDFDFDFDFDFDULL,
1318 0xFDFDFDFDFDFDFDFDULL,
1319 0x00FDFDFDFDFDFDFDULL,
1320 0x0000FDFDFDFDFDFDULL,
1321 0x000000FDFDFDFDFDULL,
1322 0x00000000FDFDFDFDULL
1323 },
1324 {
1325 0xFDFDFDFDFDFDFDFDULL,
1326 0xFDFDFDFDFDFDFDFDULL,
1327 0xFDFDFDFDFDFDFDFDULL,
1328 0xFDFDFDFDFDFDFDFDULL,
1329 0xFDFDFDFDFDFDFDFDULL,
1330 0x00FDFDFDFDFDFDFDULL,
1331 0x0000FDFDFDFDFDFDULL,
1332 0x000000FDFDFDFDFDULL
1333 },
1334 {
1335 0xFDFDFDFDFDFDFDFDULL,
1336 0xFDFDFDFDFDFDFDFDULL,
1337 0xFDFDFDFDFDFDFDFDULL,
1338 0xFDFDFDFDFDFDFDFDULL,
1339 0xFDFDFDFDFDFDFDFDULL,
1340 0xFDFDFDFDFDFDFDFDULL,
1341 0x00FDFDFDFDFDFDFDULL,
1342 0x0000FDFDFDFDFDFDULL
1343 },
1344 {
1345 0xFDFDFDFDFDFDFDFDULL,
1346 0xFDFDFDFDFDFDFDFDULL,
1347 0xFDFDFDFDFDFDFDFDULL,
1348 0xFDFDFDFDFDFDFDFDULL,
1349 0xFDFDFDFDFDFDFDFDULL,
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0x00FDFDFDFDFDFDFDULL
1353 },
1354 {
1355 0xFDFDFDFDFDFDFDFDULL,
1356 0xFDFDFDFDFDFDFDFDULL,
1357 0xFDFDFDFDFDFDFDFDULL,
1358 0xFDFDFDFDFDFDFDFDULL,
1359 0xFDFDFDFDFDFDFDFDULL,
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL
1363 }
1364 },
1365 {
1366 {
1367 0x0000000000000000ULL,
1368 0x0000000000000000ULL,
1369 0x0000000000000000ULL,
1370 0x0000000000000000ULL,
1371 0x0000000000000000ULL,
1372 0x0000000000000000ULL,
1373 0x0000000000000000ULL,
1374 0x0000000000000000ULL
1375 },
1376 {
1377 0x0000000000000000ULL,
1378 0x0000000000000000ULL,
1379 0x0000000000000000ULL,
1380 0x0000000000000000ULL,
1381 0x0000000000000000ULL,
1382 0x0000000000000000ULL,
1383 0x0000000000000000ULL,
1384 0xFD00000000000000ULL
1385 },
1386 {
1387 0x0000000000000000ULL,
1388 0x0000000000000000ULL,
1389 0x0000000000000000ULL,
1390 0x0000000000000000ULL,
1391 0x0000000000000000ULL,
1392 0x0000000000000000ULL,
1393 0xFD00000000000000ULL,
1394 0xFDFD000000000000ULL
1395 },
1396 {
1397 0x0000000000000000ULL,
1398 0x0000000000000000ULL,
1399 0x0000000000000000ULL,
1400 0x0000000000000000ULL,
1401 0x0000000000000000ULL,
1402 0xFD00000000000000ULL,
1403 0xFDFD000000000000ULL,
1404 0xFDFDFD0000000000ULL
1405 },
1406 {
1407 0x0000000000000000ULL,
1408 0x0000000000000000ULL,
1409 0x0000000000000000ULL,
1410 0x0000000000000000ULL,
1411 0xFD00000000000000ULL,
1412 0xFDFD000000000000ULL,
1413 0xFDFDFD0000000000ULL,
1414 0xFDFDFDFD00000000ULL
1415 },
1416 {
1417 0x0000000000000000ULL,
1418 0x0000000000000000ULL,
1419 0x0000000000000000ULL,
1420 0xFD00000000000000ULL,
1421 0xFDFD000000000000ULL,
1422 0xFDFDFD0000000000ULL,
1423 0xFDFDFDFD00000000ULL,
1424 0xFDFDFDFDFD000000ULL
1425 },
1426 {
1427 0x0000000000000000ULL,
1428 0x0000000000000000ULL,
1429 0xFD00000000000000ULL,
1430 0xFDFD000000000000ULL,
1431 0xFDFDFD0000000000ULL,
1432 0xFDFDFDFD00000000ULL,
1433 0xFDFDFDFDFD000000ULL,
1434 0xFDFDFDFDFDFD0000ULL
1435 },
1436 {
1437 0x0000000000000000ULL,
1438 0xFD00000000000000ULL,
1439 0xFDFD000000000000ULL,
1440 0xFDFDFD0000000000ULL,
1441 0xFDFDFDFD00000000ULL,
1442 0xFDFDFDFDFD000000ULL,
1443 0xFDFDFDFDFDFD0000ULL,
1444 0xFDFDFDFDFDFDFD00ULL
1445 },
1446 {
1447 0xFD00000000000000ULL,
1448 0xFDFD000000000000ULL,
1449 0xFDFDFD0000000000ULL,
1450 0xFDFDFDFD00000000ULL,
1451 0xFDFDFDFDFD000000ULL,
1452 0xFDFDFDFDFDFD0000ULL,
1453 0xFDFDFDFDFDFDFD00ULL,
1454 0xFDFDFDFDFDFDFDFDULL
1455 },
1456 {
1457 0xFDFD000000000000ULL,
1458 0xFDFDFD0000000000ULL,
1459 0xFDFDFDFD00000000ULL,
1460 0xFDFDFDFDFD000000ULL,
1461 0xFDFDFDFDFDFD0000ULL,
1462 0xFDFDFDFDFDFDFD00ULL,
1463 0xFDFDFDFDFDFDFDFDULL,
1464 0xFDFDFDFDFDFDFDFDULL
1465 },
1466 {
1467 0xFDFDFD0000000000ULL,
1468 0xFDFDFDFD00000000ULL,
1469 0xFDFDFDFDFD000000ULL,
1470 0xFDFDFDFDFDFD0000ULL,
1471 0xFDFDFDFDFDFDFD00ULL,
1472 0xFDFDFDFDFDFDFDFDULL,
1473 0xFDFDFDFDFDFDFDFDULL,
1474 0xFDFDFDFDFDFDFDFDULL
1475 },
1476 {
1477 0xFDFDFDFD00000000ULL,
1478 0xFDFDFDFDFD000000ULL,
1479 0xFDFDFDFDFDFD0000ULL,
1480 0xFDFDFDFDFDFDFD00ULL,
1481 0xFDFDFDFDFDFDFDFDULL,
1482 0xFDFDFDFDFDFDFDFDULL,
1483 0xFDFDFDFDFDFDFDFDULL,
1484 0xFDFDFDFDFDFDFDFDULL
1485 },
1486 {
1487 0xFDFDFDFDFD000000ULL,
1488 0xFDFDFDFDFDFD0000ULL,
1489 0xFDFDFDFDFDFDFD00ULL,
1490 0xFDFDFDFDFDFDFDFDULL,
1491 0xFDFDFDFDFDFDFDFDULL,
1492 0xFDFDFDFDFDFDFDFDULL,
1493 0xFDFDFDFDFDFDFDFDULL,
1494 0xFDFDFDFDFDFDFDFDULL
1495 },
1496 {
1497 0xFDFDFDFDFDFD0000ULL,
1498 0xFDFDFDFDFDFDFD00ULL,
1499 0xFDFDFDFDFDFDFDFDULL,
1500 0xFDFDFDFDFDFDFDFDULL,
1501 0xFDFDFDFDFDFDFDFDULL,
1502 0xFDFDFDFDFDFDFDFDULL,
1503 0xFDFDFDFDFDFDFDFDULL,
1504 0xFDFDFDFDFDFDFDFDULL
1505 },
1506 {
1507 0xFDFDFDFDFDFDFD00ULL,
1508 0xFDFDFDFDFDFDFDFDULL,
1509 0xFDFDFDFDFDFDFDFDULL,
1510 0xFDFDFDFDFDFDFDFDULL,
1511 0xFDFDFDFDFDFDFDFDULL,
1512 0xFDFDFDFDFDFDFDFDULL,
1513 0xFDFDFDFDFDFDFDFDULL,
1514 0xFDFDFDFDFDFDFDFDULL
1515 },
1516 {
1517 0xFDFDFDFDFDFDFDFDULL,
1518 0xFDFDFDFDFDFDFDFDULL,
1519 0xFDFDFDFDFDFDFDFDULL,
1520 0xFDFDFDFDFDFDFDFDULL,
1521 0xFDFDFDFDFDFDFDFDULL,
1522 0xFDFDFDFDFDFDFDFDULL,
1523 0xFDFDFDFDFDFDFDFDULL,
1524 0xFDFDFDFDFDFDFDFDULL
1525 }
1526 },
1527 {
1528 {
1529 0x0000000000000000ULL,
1530 0x0000000000000000ULL,
1531 0x0000000000000000ULL,
1532 0x0000000000000000ULL,
1533 0x0000000000000000ULL,
1534 0x0000000000000000ULL,
1535 0x0000000000000000ULL,
1536 0x0000000000000000ULL
1537 },
1538 {
1539 0x0000000000000000ULL,
1540 0x0000000000000000ULL,
1541 0x0000000000000000ULL,
1542 0x0000000000000000ULL,
1543 0x0000000000000000ULL,
1544 0x0000000000000000ULL,
1545 0x0000000000000000ULL,
1546 0x00000000000000FDULL
1547 },
1548 {
1549 0x0000000000000000ULL,
1550 0x0000000000000000ULL,
1551 0x0000000000000000ULL,
1552 0x0000000000000000ULL,
1553 0x0000000000000000ULL,
1554 0x0000000000000000ULL,
1555 0x00000000000000FDULL,
1556 0x000000000000FDFDULL
1557 },
1558 {
1559 0x0000000000000000ULL,
1560 0x0000000000000000ULL,
1561 0x0000000000000000ULL,
1562 0x0000000000000000ULL,
1563 0x0000000000000000ULL,
1564 0x00000000000000FDULL,
1565 0x000000000000FDFDULL,
1566 0x0000000000FDFDFDULL
1567 },
1568 {
1569 0x0000000000000000ULL,
1570 0x0000000000000000ULL,
1571 0x0000000000000000ULL,
1572 0x0000000000000000ULL,
1573 0x00000000000000FDULL,
1574 0x000000000000FDFDULL,
1575 0x0000000000FDFDFDULL,
1576 0x00000000FDFDFDFDULL
1577 },
1578 {
1579 0x0000000000000000ULL,
1580 0x0000000000000000ULL,
1581 0x0000000000000000ULL,
1582 0x00000000000000FDULL,
1583 0x000000000000FDFDULL,
1584 0x0000000000FDFDFDULL,
1585 0x00000000FDFDFDFDULL,
1586 0x000000FDFDFDFDFDULL
1587 },
1588 {
1589 0x0000000000000000ULL,
1590 0x0000000000000000ULL,
1591 0x00000000000000FDULL,
1592 0x000000000000FDFDULL,
1593 0x0000000000FDFDFDULL,
1594 0x00000000FDFDFDFDULL,
1595 0x000000FDFDFDFDFDULL,
1596 0x0000FDFDFDFDFDFDULL
1597 },
1598 {
1599 0x0000000000000000ULL,
1600 0x00000000000000FDULL,
1601 0x000000000000FDFDULL,
1602 0x0000000000FDFDFDULL,
1603 0x00000000FDFDFDFDULL,
1604 0x000000FDFDFDFDFDULL,
1605 0x0000FDFDFDFDFDFDULL,
1606 0x00FDFDFDFDFDFDFDULL
1607 },
1608 {
1609 0x00000000000000FDULL,
1610 0x000000000000FDFDULL,
1611 0x0000000000FDFDFDULL,
1612 0x00000000FDFDFDFDULL,
1613 0x000000FDFDFDFDFDULL,
1614 0x0000FDFDFDFDFDFDULL,
1615 0x00FDFDFDFDFDFDFDULL,
1616 0xFDFDFDFDFDFDFDFDULL
1617 },
1618 {
1619 0x000000000000FDFDULL,
1620 0x0000000000FDFDFDULL,
1621 0x00000000FDFDFDFDULL,
1622 0x000000FDFDFDFDFDULL,
1623 0x0000FDFDFDFDFDFDULL,
1624 0x00FDFDFDFDFDFDFDULL,
1625 0xFDFDFDFDFDFDFDFDULL,
1626 0xFDFDFDFDFDFDFDFDULL
1627 },
1628 {
1629 0x0000000000FDFDFDULL,
1630 0x00000000FDFDFDFDULL,
1631 0x000000FDFDFDFDFDULL,
1632 0x0000FDFDFDFDFDFDULL,
1633 0x00FDFDFDFDFDFDFDULL,
1634 0xFDFDFDFDFDFDFDFDULL,
1635 0xFDFDFDFDFDFDFDFDULL,
1636 0xFDFDFDFDFDFDFDFDULL
1637 },
1638 {
1639 0x00000000FDFDFDFDULL,
1640 0x000000FDFDFDFDFDULL,
1641 0x0000FDFDFDFDFDFDULL,
1642 0x00FDFDFDFDFDFDFDULL,
1643 0xFDFDFDFDFDFDFDFDULL,
1644 0xFDFDFDFDFDFDFDFDULL,
1645 0xFDFDFDFDFDFDFDFDULL,
1646 0xFDFDFDFDFDFDFDFDULL
1647 },
1648 {
1649 0x000000FDFDFDFDFDULL,
1650 0x0000FDFDFDFDFDFDULL,
1651 0x00FDFDFDFDFDFDFDULL,
1652 0xFDFDFDFDFDFDFDFDULL,
1653 0xFDFDFDFDFDFDFDFDULL,
1654 0xFDFDFDFDFDFDFDFDULL,
1655 0xFDFDFDFDFDFDFDFDULL,
1656 0xFDFDFDFDFDFDFDFDULL
1657 },
1658 {
1659 0x0000FDFDFDFDFDFDULL,
1660 0x00FDFDFDFDFDFDFDULL,
1661 0xFDFDFDFDFDFDFDFDULL,
1662 0xFDFDFDFDFDFDFDFDULL,
1663 0xFDFDFDFDFDFDFDFDULL,
1664 0xFDFDFDFDFDFDFDFDULL,
1665 0xFDFDFDFDFDFDFDFDULL,
1666 0xFDFDFDFDFDFDFDFDULL
1667 },
1668 {
1669 0x00FDFDFDFDFDFDFDULL,
1670 0xFDFDFDFDFDFDFDFDULL,
1671 0xFDFDFDFDFDFDFDFDULL,
1672 0xFDFDFDFDFDFDFDFDULL,
1673 0xFDFDFDFDFDFDFDFDULL,
1674 0xFDFDFDFDFDFDFDFDULL,
1675 0xFDFDFDFDFDFDFDFDULL,
1676 0xFDFDFDFDFDFDFDFDULL
1677 },
1678 {
1679 0xFDFDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL,
1681 0xFDFDFDFDFDFDFDFDULL,
1682 0xFDFDFDFDFDFDFDFDULL,
1683 0xFDFDFDFDFDFDFDFDULL,
1684 0xFDFDFDFDFDFDFDFDULL,
1685 0xFDFDFDFDFDFDFDFDULL,
1686 0xFDFDFDFDFDFDFDFDULL
1687 }
1688 }
1689 };
1690
1691 int32_t black_opening_count=0;
1692 int32_t black_opening_x,black_opening_y;
1693 int32_t black_opening_shape;
1694
1695 38 int32_t choose_opening_shape()
1696 {
1697 // First, count how many bits are set
1698 38 int32_t numBits=0;
1699 int32_t bitCounter;
1700
1701
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 38 times.
228 for(int32_t i=0; i<bosMAX; i++)
1702 {
1703
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 if(COOLSCROLL&(1<<i))
1704 38 numBits++;
1705 190 }
1706
1707 // Shouldn't happen...
1708
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(numBits==0)
1709 return bosCIRCLE;
1710
1711 // Pick a bit
1712 38 bitCounter=zc_rand()%numBits+1;
1713
1714
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 for(int32_t i=0; i<bosMAX; i++)
1715 {
1716 // If this bit is set, decrement the bit counter
1717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(COOLSCROLL&(1<<i))
1718 38 bitCounter--;
1719
1720 // When the counter hits 0, return a value based on
1721 // which bit it stopped on.
1722 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1723
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(bitCounter==0)
1724 38 return i;
1725 }
1726
1727 // Shouldn't be necessary, but the compiler might complain, at least
1728 return bosCIRCLE;
1729 38 }
1730
1731 8 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1732 {
1733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1734
1735 8 int32_t w=256, h=224;
1736 8 int32_t blockrows=28, blockcolumns=32;
1737 8 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1738
1739
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 8 times.
232 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1740 {
1741
2/2
✓ Branch 0 taken 7168 times.
✓ Branch 1 taken 224 times.
7392 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1742 {
1743
2/2
✓ Branch 0 taken 3738 times.
✓ Branch 1 taken 3430 times.
7168 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1744 7168 }
1745 224 }
1746
1747 8 black_opening_count = 66;
1748 8 black_opening_x = x;
1749 8 black_opening_y = y;
1750 8 lensclk = 0;
1751 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1752
1753
1754
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(black_opening_shape == bosFADEBLACK)
1755 {
1756 refreshTints();
1757 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1758 }
1759
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(wait)
1760 {
1761 FFCore.warpScriptCheck();
1762 for(int32_t i=0; i<66; i++)
1763 {
1764 draw_screen(tmpscr);
1765 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1766 syskeys();
1767 advanceframe(true);
1768
1769 if(Quit)
1770 {
1771 break;
1772 }
1773 }
1774 }
1775 8 }
1776
1777 30 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1778 {
1779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1780
1781 30 int32_t w=256, h=224;
1782 30 int32_t blockrows=28, blockcolumns=32;
1783 30 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1784
1785
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 30 times.
870 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1786 {
1787
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 840 times.
27720 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1788 {
1789
2/2
✓ Branch 0 taken 11253 times.
✓ Branch 1 taken 15627 times.
26880 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1790 26880 }
1791 840 }
1792
1793 30 black_opening_count = -66;
1794 30 black_opening_x = x;
1795 30 black_opening_y = y;
1796 30 lensclk = 0;
1797
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(black_opening_shape == bosFADEBLACK)
1798 {
1799 refreshTints();
1800 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1801 }
1802
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 25 times.
30 if(wait)
1803 {
1804 25 FFCore.warpScriptCheck();
1805
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 1650 times.
1675 for(int32_t i=0; i<66; i++)
1806 {
1807 1650 draw_screen(tmpscr);
1808 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1809 1650 syskeys();
1810 1650 advanceframe(true);
1811
1812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1650 times.
1650 if(Quit)
1813 {
1814 break;
1815 }
1816 1650 }
1817 25 }
1818 30 }
1819
1820 2508 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1821 {
1822 2508 clear_to_color(tmp_scr,BLACK);
1823 2508 int32_t w=256, h=224;
1824
1825
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2508 times.
2508 switch(black_opening_shape)
1826 {
1827 case bosOVAL:
1828 {
1829 double new_w=(w/2)+abs(w/2-x);
1830 double new_h=(h/2)+abs(h/2-y);
1831 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1832 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1833 break;
1834 }
1835
1836 case bosTRIANGLE:
1837 {
1838 double new_w=(w/2)+abs(w/2-x);
1839 double new_h=(h/2)+abs(h/2-y);
1840 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1841 double P2= (PI/2);
1842 double P23=(2*PI/3);
1843 double P43=(4*PI/3);
1844 double Pa= (-4*PI*a/(3*max_a));
1845 double angle=P2+Pa;
1846 double a0=angle;
1847 double a2=angle+P23;
1848 double a4=angle+P43;
1849 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1850 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1851 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1852 0);
1853 break;
1854 }
1855
1856 case bosSMAS:
1857 {
1858 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1859
1860 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1861 {
1862 for(int32_t linerow=0; linerow<8; ++linerow)
1863 {
1864 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1865
1866 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1867 {
1868 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1869 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1870 [linerow];
1871 ++triangleline;
1872
1873 if(linerow==0)
1874 {
1875 }
1876 }
1877 }
1878 }
1879
1880 break;
1881 }
1882
1883 case bosFADEBLACK:
1884 {
1885 if(black_opening_count<0)
1886 {
1887 black_fade(zc_min(-black_opening_count,63));
1888 }
1889 else if(black_opening_count>0)
1890 {
1891 black_fade(63-zc_max(black_opening_count-3,0));
1892 }
1893 else black_fade(0);
1894 return; //no blitting from tmp_scr!
1895 }
1896
1897 2508 case bosCIRCLE:
1898 default:
1899 {
1900 2508 double new_w=(w/2)+abs(w/2-x);
1901 2508 double new_h=(h/2)+abs(h/2-y);
1902 2508 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1903 //circlefill(tmp_scr,x,y,a<<3,0);
1904 2508 circlefill(tmp_scr,x,y,r,0);
1905 2508 break;
1906 }
1907 }
1908
1909 2508 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1910 2508 }
1911
1912
1913 void black_fade(int32_t fadeamnt)
1914 {
1915 for(int32_t i=0; i < 0xEF; i++)
1916 {
1917 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1918 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1919 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1920 }
1921
1922 refreshpal = true;
1923 }
1924
1925 //----------------------------------------------------------------
1926
1927 211189 bool item_disabled(int32_t item) //is this item disabled?
1928 {
1929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 211189 times.
211189 return (item>=0 && game->items_off[item] != 0);
1930 }
1931
1932 548136 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1933 {
1934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 548136 times.
548136 if(current_item(item_type, true) >=item)
1935 {
1936 return true;
1937 }
1938
1939 548136 return false;
1940 548136 }
1941
1942 2616091 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1943 {
1944
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 390776 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 173616 times.
✓ Branch 6 taken 1543548 times.
✓ Branch 7 taken 505882 times.
✓ Branch 8 taken 2269 times.
2616091 switch(item_type)
1945 {
1946 case itype_bomb:
1947 case itype_sbomb:
1948 {
1949 int32_t itemid = getItemID(itemsbuf, item_type, it);
1950
1951 if(itemid == -1)
1952 return false;
1953
1954 return (game->get_item(itemid));
1955 }
1956
1957 case itype_clock:
1958 {
1959 390776 int32_t itemid = getItemID(itemsbuf, item_type, it);
1960
1961
2/4
✓ Branch 0 taken 390776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 390776 times.
✗ Branch 3 not taken.
390776 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1962 return (game->get_item(itemid));
1963 390776 return Hero.getClock()?1:0;
1964 }
1965
1966 case itype_key:
1967 return (game->get_keys()>0);
1968
1969 case itype_magiccontainer:
1970 return (game->get_maxmagic()>=game->get_mp_per_block());
1971
1972 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1973 {
1974
1/3
✓ Branch 0 taken 173616 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
173616 switch(it)
1975 {
1976 case -2:
1977 {
1978 for(int32_t i=0; i<MAXLEVELS; i++)
1979 {
1980 if(game->lvlitems[i]&liTRIFORCE)
1981 {
1982 return true;
1983 }
1984 }
1985
1986 return false;
1987 }
1988
1989 case -1:
1990 return (game->lvlitems[dlevel]&liTRIFORCE);
1991
1992 default:
1993
2/4
✓ Branch 0 taken 173616 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 173616 times.
173616 if(it>=0&&it<MAXLEVELS)
1994 {
1995 173616 return (game->lvlitems[it]&liTRIFORCE);
1996 }
1997
1998 break;
1999 }
2000
2001 return 0;
2002 }
2003
2004 case itype_map: //it: -2=any, -1=current level, other=that level
2005 {
2006
1/3
✓ Branch 0 taken 1543548 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
1543548 switch(it)
2007 {
2008 case -2:
2009 {
2010 for(int32_t i=0; i<MAXLEVELS; i++)
2011 {
2012 if(game->lvlitems[i]&liMAP)
2013 {
2014 return true;
2015 }
2016 }
2017
2018 return false;
2019 }
2020
2021 case -1:
2022 return (game->lvlitems[dlevel]&liMAP)!=0;
2023
2024 default:
2025
2/4
✓ Branch 0 taken 1543548 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1543548 times.
1543548 if(it>=0&&it<MAXLEVELS)
2026 {
2027 1543548 return (game->lvlitems[it]&liMAP)!=0;
2028 }
2029
2030 break;
2031 }
2032
2033 return 0;
2034 }
2035
2036 case itype_compass: //it: -2=any, -1=current level, other=that level
2037 {
2038
1/3
✓ Branch 0 taken 505882 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
505882 switch(it)
2039 {
2040 case -2:
2041 {
2042 for(int32_t i=0; i<MAXLEVELS; i++)
2043 {
2044 if(game->lvlitems[i]&liCOMPASS)
2045 {
2046 return true;
2047 }
2048 }
2049
2050 return false;
2051 }
2052
2053 case -1:
2054 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2055
2056 default:
2057
2/4
✓ Branch 0 taken 505882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 505882 times.
✗ Branch 3 not taken.
505882 if(it>=0&&it<MAXLEVELS)
2058 {
2059 505882 return (game->lvlitems[it]&liCOMPASS)!=0;
2060 }
2061
2062 break;
2063 }
2064 return 0;
2065 }
2066
2067 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2068 {
2069
1/3
✓ Branch 0 taken 2269 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2269 switch(it)
2070 {
2071 case -2:
2072 {
2073 for(int32_t i=0; i<MAXLEVELS; i++)
2074 {
2075 if(game->lvlitems[i]&liBOSSKEY)
2076 {
2077 return true;
2078 }
2079 }
2080
2081 return false;
2082 }
2083
2084 case -1:
2085 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2086
2087 default:
2088
2/4
✓ Branch 0 taken 2269 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2269 times.
2269 if(it>=0&&it<MAXLEVELS)
2089 {
2090 2269 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2091 }
2092 break;
2093 }
2094 return 0;
2095 }
2096
2097 default:
2098 //it=(1<<(it-1));
2099 /*if (item_type>=itype_max)
2100 {
2101 system_pal();
2102 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,lfont);
2103 game_pal();
2104
2105 return false;
2106 }*/
2107 int32_t itemid = getItemID(itemsbuf, item_type, it);
2108
2109 if(itemid == -1)
2110 return false;
2111
2112 return game->get_item(itemid);
2113 }
2114 2616091 }
2115
2116
2117 6606015 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2118 {
2119
9/9
✓ Branch 0 taken 390776 times.
✓ Branch 1 taken 3479807 times.
✓ Branch 2 taken 390776 times.
✓ Branch 3 taken 390776 times.
✓ Branch 4 taken 390776 times.
✓ Branch 5 taken 390776 times.
✓ Branch 6 taken 390776 times.
✓ Branch 7 taken 390776 times.
✓ Branch 8 taken 390776 times.
6606015 switch(item_type)
2120 {
2121 case itype_clock:
2122 {
2123 390776 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2124
2125
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 390776 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
390776 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2126 return itemsbuf[maxid].fam_type;
2127
2128 390776 return has_item(itype_clock,1) ? 1 : 0;
2129 }
2130
2131 case itype_key:
2132 390776 return game->get_keys();
2133
2134 case itype_lkey:
2135 390776 return game->lvlkeys[get_dlevel()];
2136
2137 case itype_magiccontainer:
2138 390776 return game->get_maxmagic()/game->get_mp_per_block();
2139
2140 case itype_triforcepiece:
2141 {
2142 390776 int32_t count=0;
2143
2144
2/2
✓ Branch 0 taken 200077312 times.
✓ Branch 1 taken 390776 times.
200468088 for(int32_t i=0; i<MAXLEVELS; i++)
2145 {
2146 200077312 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2147 200077312 }
2148
2149 390776 return count;
2150 }
2151
2152 case itype_map:
2153 {
2154 390776 int32_t count=0;
2155
2156
2/2
✓ Branch 0 taken 200077312 times.
✓ Branch 1 taken 390776 times.
200468088 for(int32_t i=0; i<MAXLEVELS; i++)
2157 {
2158 200077312 count+=(game->lvlitems[i]&liMAP)?1:0;
2159 200077312 }
2160
2161 390776 return count;
2162 }
2163
2164 case itype_compass:
2165 {
2166 390776 int32_t count=0;
2167
2168
2/2
✓ Branch 0 taken 200077312 times.
✓ Branch 1 taken 390776 times.
200468088 for(int32_t i=0; i<MAXLEVELS; i++)
2169 {
2170 200077312 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2171 200077312 }
2172
2173 390776 return count;
2174 }
2175
2176 case itype_bosskey:
2177 {
2178 390776 int32_t count=0;
2179
2180
2/2
✓ Branch 0 taken 200077312 times.
✓ Branch 1 taken 390776 times.
200468088 for(int32_t i=0; i<MAXLEVELS; i++)
2181 {
2182 200077312 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2183 200077312 }
2184
2185 390776 return count;
2186 }
2187
2188 default:
2189 3479807 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2190
2191
2/2
✓ Branch 0 taken 119125 times.
✓ Branch 1 taken 3360682 times.
3479807 if(maxid == -1)
2192 3360682 return 0;
2193
2194 119125 return itemsbuf[maxid].fam_type;
2195 }
2196 6606015 }
2197
2198 6057879 int32_t current_item(int32_t item_type) //item currently being used
2199 {
2200 6057879 return current_item(item_type, true);
2201 }
2202
2203 9 std::map<int32_t, int32_t> itemcache;
2204
2205 // Not actually used by anything at the moment...
2206 void removeFromItemCache(int32_t itemid)
2207 {
2208 itemcache.erase(itemid);
2209 }
2210
2211 1229 void flushItemCache()
2212 {
2213 1229 itemcache.clear();
2214
2215 //also fix the active subscreen if items were deleted -DD
2216
1/2
✓ Branch 0 taken 1229 times.
✗ Branch 1 not taken.
1229 if(game != NULL)
2217 {
2218 1229 verifyBothWeapons();
2219 1229 load_Sitems(&QMisc);
2220 1229 }
2221 1229 }
2222
2223 // This is used often, so it should be as direct as possible.
2224 214891376 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2225 {
2226
2/2
✓ Branch 0 taken 211365675 times.
✓ Branch 1 taken 3525701 times.
214891376 if(jinx_check)
2227 {
2228
4/4
✓ Branch 0 taken 2495543 times.
✓ Branch 1 taken 1030158 times.
✓ Branch 2 taken 2392000 times.
✓ Branch 3 taken 103543 times.
3525701 if(!(HeroSwordClk() || HeroItemClk()))
2229 2392000 jinx_check = false; //not jinxed
2230 3525701 }
2231
4/4
✓ Branch 0 taken 213934573 times.
✓ Branch 1 taken 956803 times.
✓ Branch 2 taken 1129605 times.
✓ Branch 3 taken 212804968 times.
214891376 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2232 {
2233 212804968 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2234
2235
2/2
✓ Branch 0 taken 212177483 times.
✓ Branch 1 taken 627485 times.
212804968 if(res != itemcache.end())
2236 212177483 return res->second;
2237 627485 }
2238
2239 2713893 int32_t result = -1;
2240 2713893 int32_t highestlevel = -1;
2241
2242
2/2
✓ Branch 0 taken 694756608 times.
✓ Branch 1 taken 2713893 times.
697470501 for(int32_t i=0; i<MAXITEMS; i++)
2243 {
2244
5/6
✓ Branch 0 taken 30317449 times.
✓ Branch 1 taken 664439159 times.
✓ Branch 2 taken 203117 times.
✓ Branch 3 taken 30114332 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 203117 times.
694756608 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2245 {
2246
4/4
✓ Branch 0 taken 88692 times.
✓ Branch 1 taken 114425 times.
✓ Branch 2 taken 39371 times.
✓ Branch 3 taken 163746 times.
203117 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2247 {
2248 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2249
2/2
✓ Branch 0 taken 163744 times.
✓ Branch 1 taken 2 times.
163746 if(!checkmagiccost(i))
2250 {
2251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2252 }
2253 163744 }
2254
6/6
✓ Branch 0 taken 129221 times.
✓ Branch 1 taken 73894 times.
✓ Branch 2 taken 12873 times.
✓ Branch 3 taken 61021 times.
✓ Branch 4 taken 56725 times.
✓ Branch 5 taken 17169 times.
203115 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2255 {
2256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17169 times.
17169 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2257 17169 continue;
2258 }
2259
2260
2/2
✓ Branch 0 taken 15294 times.
✓ Branch 1 taken 170652 times.
185946 if(itemsbuf[i].fam_type >= highestlevel)
2261 {
2262 170652 highestlevel = itemsbuf[i].fam_type;
2263 170652 result=i;
2264 170652 }
2265 185946 }
2266 694739437 }
2267
2268
2/2
✓ Branch 0 taken 1133701 times.
✓ Branch 1 taken 1580192 times.
2713893 if(!jinx_check) //Can't cache jinx_check results
2269 1580192 itemcache[itemtype] = result;
2270 2713893 return result;
2271 214891376 }
2272
2273 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2274 213772864 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2275 {
2276 213772864 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2277
2/2
✓ Branch 0 taken 2407189 times.
✓ Branch 1 taken 211365675 times.
213772864 if(!jinx_check) //If not already a jinx-immune-only check...
2278 {
2279 //And the player IS jinxed...
2280
4/4
✓ Branch 0 taken 210349294 times.
✓ Branch 1 taken 1016381 times.
✓ Branch 2 taken 102131 times.
✓ Branch 3 taken 210247163 times.
211365675 if(HeroSwordClk() || HeroItemClk())
2281 {
2282 //Then do a jinx-immune-only check here
2283 1118512 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2284 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2285 //Should NOT need a compat rule, as this should always return -1 in old quests.
2286
2/2
✓ Branch 0 taken 31330 times.
✓ Branch 1 taken 1087182 times.
1118512 if(ret2 > -1) return ret2;
2287 1087182 }
2288 211334345 }
2289 213741534 return ret;
2290 213772864 }
2291 1385639 int32_t current_item_power(int32_t itemtype)
2292 {
2293 1385639 int32_t result = current_item_id(itemtype,true);
2294
2/2
✓ Branch 0 taken 1340502 times.
✓ Branch 1 taken 45137 times.
1385639 return (result<0) ? 0 : itemsbuf[result].power;
2295 }
2296
2297 int32_t heart_container_id()
2298 {
2299 for(int32_t i=0; i<MAXITEMS; i++)
2300 {
2301 if(itemsbuf[i].family == itype_heartcontainer)
2302 {
2303 return i;
2304 }
2305 }
2306 return -1;
2307 }
2308
2309 390776 int32_t item_tile_mod()
2310 {
2311 390776 int32_t tile=0;
2312
2313
2/2
✓ Branch 0 taken 31669 times.
✓ Branch 1 taken 359107 times.
390776 if(game->get_bombs())
2314 {
2315 359107 int32_t itemid = current_item_id(itype_bomb,false);
2316
3/4
✓ Branch 0 taken 358738 times.
✓ Branch 1 taken 369 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 358738 times.
359107 if(itemid > -1 && checkbunny(itemid))
2317 358738 tile+=itemsbuf[itemid].ltm;
2318 359107 }
2319
2320
2/2
✓ Branch 0 taken 379982 times.
✓ Branch 1 taken 10794 times.
390776 if(game->get_sbombs())
2321 {
2322 10794 int32_t itemid = current_item_id(itype_sbomb,false);
2323
3/4
✓ Branch 0 taken 4127 times.
✓ Branch 1 taken 6667 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4127 times.
10794 if(itemid > -1 && checkbunny(itemid))
2324 4127 tile+=itemsbuf[itemid].ltm;
2325 10794 }
2326
2327
2/2
✓ Branch 0 taken 382267 times.
✓ Branch 1 taken 8509 times.
390776 if(current_item(itype_clock))
2328 {
2329 8509 int32_t itemid =
2330
1/2
✓ Branch 0 taken 8509 times.
✗ Branch 1 not taken.
8509 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2331 ? iClock
2332 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2333
2/4
✓ Branch 0 taken 8509 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8509 times.
8509 if(itemid > -1 && checkbunny(itemid))
2334 8509 tile+=itemsbuf[itemid].ltm;
2335 8509 }
2336
2337
2/2
✓ Branch 0 taken 211070 times.
✓ Branch 1 taken 179706 times.
390776 if(current_item(itype_key))
2338 {
2339 179706 int32_t itemid =
2340
1/2
✓ Branch 0 taken 179706 times.
✗ Branch 1 not taken.
179706 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2341 ? iKey
2342 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2343
2/4
✓ Branch 0 taken 179706 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 179706 times.
179706 if(itemid > -1 && checkbunny(itemid))
2344 179706 tile+=itemsbuf[itemid].ltm;
2345 179706 }
2346
2347
1/2
✓ Branch 0 taken 390776 times.
✗ Branch 1 not taken.
390776 if(current_item(itype_lkey))
2348 {
2349 int32_t itemid =
2350 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2351 ? iLevelKey
2352 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2353 if(itemid > -1 && checkbunny(itemid))
2354 tile+=itemsbuf[itemid].ltm;
2355 }
2356
2357
2/2
✓ Branch 0 taken 132427 times.
✓ Branch 1 taken 258349 times.
390776 if(current_item(itype_map))
2358 {
2359 258349 int32_t itemid =
2360
1/2
✓ Branch 0 taken 258349 times.
✗ Branch 1 not taken.
258349 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2361 ? iMap
2362 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2363
2/4
✓ Branch 0 taken 258349 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 258349 times.
258349 if(itemid > -1 && checkbunny(itemid))
2364 258349 tile+=itemsbuf[itemid].ltm;
2365 258349 }
2366
2367
2/2
✓ Branch 0 taken 73812 times.
✓ Branch 1 taken 316964 times.
390776 if(current_item(itype_compass))
2368 {
2369 316964 int32_t itemid =
2370
1/2
✓ Branch 0 taken 316964 times.
✗ Branch 1 not taken.
316964 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2371 ? iCompass
2372 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2373
2/4
✓ Branch 0 taken 316964 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 316964 times.
316964 if(itemid > -1 && checkbunny(itemid))
2374 316964 tile+=itemsbuf[itemid].ltm;
2375 316964 }
2376
2377
2/2
✓ Branch 0 taken 250384 times.
✓ Branch 1 taken 140392 times.
390776 if(current_item(itype_bosskey))
2378 {
2379 140392 int32_t itemid =
2380
1/2
✓ Branch 0 taken 140392 times.
✗ Branch 1 not taken.
140392 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2381 ? iBossKey
2382 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2383
2/4
✓ Branch 0 taken 140392 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140392 times.
140392 if(itemid > -1 && checkbunny(itemid))
2384 140392 tile+=itemsbuf[itemid].ltm;
2385 140392 }
2386
2387
1/2
✓ Branch 0 taken 390776 times.
✗ Branch 1 not taken.
390776 if(current_item(itype_magiccontainer))
2388 {
2389 int32_t itemid =
2390 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2391 ? iMagicC
2392 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2393 if(itemid > -1 && checkbunny(itemid))
2394 tile+=itemsbuf[itemid].ltm;
2395 }
2396
2397
2/2
✓ Branch 0 taken 67810 times.
✓ Branch 1 taken 322966 times.
390776 if(current_item(itype_triforcepiece))
2398 {
2399 322966 int32_t itemid =
2400
1/2
✓ Branch 0 taken 322966 times.
✗ Branch 1 not taken.
322966 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2401 ? iTriforce
2402 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2403
2/4
✓ Branch 0 taken 322966 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 322966 times.
322966 if(itemid > -1 && checkbunny(itemid))
2404 322966 tile+=itemsbuf[itemid].ltm;
2405 322966 }
2406
2407
2/2
✓ Branch 0 taken 390776 times.
✓ Branch 1 taken 200077312 times.
200468088 for(int32_t i=0; i<itype_max; i++)
2408 {
2409
2/2
✓ Branch 0 taken 194590208 times.
✓ Branch 1 taken 5487104 times.
200077312 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2410 {
2411
2/2
✓ Branch 0 taken 107170 times.
✓ Branch 1 taken 5379934 times.
5487104 switch(i)
2412 {
2413 case itype_bomb:
2414 case itype_sbomb:
2415 case itype_clock:
2416 case itype_key:
2417 case itype_lkey:
2418 case itype_map:
2419 case itype_compass:
2420 case itype_bosskey:
2421 case itype_magiccontainer:
2422 case itype_triforcepiece:
2423 107170 continue; //already handled
2424 }
2425 5379934 }
2426 199970142 int32_t itemid = current_item_id(i,false);
2427
2/2
✓ Branch 0 taken 199579366 times.
✓ Branch 1 taken 390776 times.
199970142 if(i == itype_shield)
2428 390776 itemid = getCurrentShield(false);
2429
2430
3/4
✓ Branch 0 taken 3030121 times.
✓ Branch 1 taken 196940021 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3030121 times.
199970142 if(itemid < 0 || !checkbunny(itemid))
2431 196940021 continue;
2432
2433 3030121 itemdata const& itm = itemsbuf[itemid];
2434
2435
2/2
✓ Branch 0 taken 2639345 times.
✓ Branch 1 taken 390776 times.
3030121 switch(itm.family)
2436 {
2437 case itype_shield:
2438
1/2
✓ Branch 0 taken 390776 times.
✗ Branch 1 not taken.
390776 if(itm.flags & ITEM_FLAG9) //active shield
2439 {
2440 if(!usingActiveShield(itemid))
2441 {
2442 tile+=itm.misc6; //'Inactive PTM'
2443 continue;
2444 }
2445 }
2446 390776 break;
2447 }
2448
2449 3030121 tile+=itm.ltm;
2450 3030121 }
2451
2452 390776 return tile;
2453 }
2454
2455 390776 int32_t bunny_tile_mod()
2456 {
2457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 390776 times.
390776 if(Hero.BunnyClock())
2458 {
2459 return game->get_bunny_ltm();
2460 }
2461 390776 return 0;
2462 390776 }
2463
2464 // Hints are drawn on a separate layer to combo reveals.
2465 void draw_lens_under(BITMAP *dest, bool layer)
2466 {
2467 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2468 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2469 //Lens flag 3: Don't show armos/chest/dive items
2470 //Lens flag 4: Show Raft Paths
2471 //Lens flag 5: Show Invisible Enemies
2472 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2473
2474 int32_t strike_hint_table[11]=
2475 {
2476 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2477 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2478 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2479 };
2480
2481 // int32_t page = tmpscr->cpage;
2482 {
2483 int32_t blink_rate=((get_bit(quest_rules,qr_EPILEPSY) || epilepsyFlashReduction)?6:1);
2484 // int32_t temptimer=0;
2485 int32_t tempitem, tempweapon=0;
2486 strike_hint=strike_hint_table[strike_hint_counter];
2487
2488 if(strike_hint_timer>32)
2489 {
2490 strike_hint_timer=0;
2491 strike_hint_counter=((strike_hint_counter+1)%11);
2492 }
2493
2494 ++strike_hint_timer;
2495
2496 for(int32_t i=0; i<176; i++)
2497 {
2498 int32_t x = (i & 15) << 4;
2499 int32_t y = (i & 0xF0) + playing_field_offset;
2500 int32_t tempitemx=-16, tempitemy=-16;
2501 int32_t tempweaponx=-16, tempweapony=-16;
2502
2503 for(int32_t iter=0; iter<2; ++iter)
2504 {
2505 int32_t checkflag=0;
2506
2507 if(iter==0)
2508 {
2509 checkflag=combobuf[tmpscr->data[i]].flag;
2510 }
2511 else
2512 {
2513 checkflag=tmpscr->sflag[i];
2514 }
2515
2516 if(checkflag==mfSTRIKE)
2517 {
2518 if(!hints)
2519 {
2520 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2521 }
2522 else
2523 {
2524 checkflag = strike_hint;
2525 }
2526 }
2527
2528 switch(checkflag)
2529 {
2530 case 0:
2531 case mfZELDA:
2532 case mfPUSHED:
2533 case mfENEMY0:
2534 case mfENEMY1:
2535 case mfENEMY2:
2536 case mfENEMY3:
2537 case mfENEMY4:
2538 case mfENEMY5:
2539 case mfENEMY6:
2540 case mfENEMY7:
2541 case mfENEMY8:
2542 case mfENEMY9:
2543 case mfSINGLE:
2544 case mfSINGLE16:
2545 case mfNOENEMY:
2546 case mfTRAP_H:
2547 case mfTRAP_V:
2548 case mfTRAP_4:
2549 case mfTRAP_LR:
2550 case mfTRAP_UD:
2551 case mfNOGROUNDENEMY:
2552 case mfNOBLOCKS:
2553 case mfSCRIPT1:
2554 case mfSCRIPT2:
2555 case mfSCRIPT3:
2556 case mfSCRIPT4:
2557 case mfSCRIPT5:
2558 case mfSCRIPT6:
2559 case mfSCRIPT7:
2560 case mfSCRIPT8:
2561 case mfSCRIPT9:
2562 case mfSCRIPT10:
2563 case mfSCRIPT11:
2564 case mfSCRIPT12:
2565 case mfSCRIPT13:
2566 case mfSCRIPT14:
2567 case mfSCRIPT15:
2568 case mfSCRIPT16:
2569 case mfSCRIPT17:
2570 case mfSCRIPT18:
2571 case mfSCRIPT19:
2572 case mfSCRIPT20:
2573 case mfPITHOLE:
2574 case mfPITFALLFLOOR:
2575 case mfLAVA:
2576 case mfICE:
2577 case mfICEDAMAGE:
2578 case mfDAMAGE1:
2579 case mfDAMAGE2:
2580 case mfDAMAGE4:
2581 case mfDAMAGE8:
2582 case mfDAMAGE16:
2583 case mfDAMAGE32:
2584 case mfFREEZEALL:
2585 case mfFREZEALLANSFFCS:
2586 case mfFREEZEFFCSOLY:
2587 case mfSCRITPTW1TRIG:
2588 case mfSCRITPTW2TRIG:
2589 case mfSCRITPTW3TRIG:
2590 case mfSCRITPTW4TRIG:
2591 case mfSCRITPTW5TRIG:
2592 case mfSCRITPTW6TRIG:
2593 case mfSCRITPTW7TRIG:
2594 case mfSCRITPTW8TRIG:
2595 case mfSCRITPTW9TRIG:
2596 case mfSCRITPTW10TRIG:
2597 case mfTROWEL:
2598 case mfTROWELNEXT:
2599 case mfTROWELSPECIALITEM:
2600 case mfSLASHPOT:
2601 case mfLIFTPOT:
2602 case mfLIFTORSLASH:
2603 case mfLIFTROCK:
2604 case mfLIFTROCKHEAVY:
2605 case mfDROPITEM:
2606 case mfSPECIALITEM:
2607 case mfDROPKEY:
2608 case mfDROPLKEY:
2609 case mfDROPCOMPASS:
2610 case mfDROPMAP:
2611 case mfDROPBOSSKEY:
2612 case mfSPAWNNPC:
2613 case mfSWITCHHOOK:
2614 case mfSIDEVIEWLADDER:
2615 case mfSIDEVIEWPLATFORM:
2616 case mfNOENEMYSPAWN:
2617 case mfENEMYALL:
2618 case mfNOMIRROR:
2619 case mfUNSAFEGROUND:
2620 case mf168:
2621 case mf169:
2622 case mf170:
2623 case mf171:
2624 case mf172:
2625 case mf173:
2626 case mf174:
2627 case mf175:
2628 case mf176:
2629 case mf177:
2630 case mf178:
2631 case mf179:
2632 case mf180:
2633 case mf181:
2634 case mf182:
2635 case mf183:
2636 case mf184:
2637 case mf185:
2638 case mf186:
2639 case mf187:
2640 case mf188:
2641 case mf189:
2642 case mf190:
2643 case mf191:
2644 case mf192:
2645 case mf193:
2646 case mf194:
2647 case mf195:
2648 case mf196:
2649 case mf197:
2650 case mf198:
2651 case mf199:
2652 case mf200:
2653 case mf201:
2654 case mf202:
2655 case mf203:
2656 case mf204:
2657 case mf205:
2658 case mf206:
2659 case mf207:
2660 case mf208:
2661 case mf209:
2662 case mf210:
2663 case mf211:
2664 case mf212:
2665 case mf213:
2666 case mf214:
2667 case mf215:
2668 case mf216:
2669 case mf217:
2670 case mf218:
2671 case mf219:
2672 case mf220:
2673 case mf221:
2674 case mf222:
2675 case mf223:
2676 case mf224:
2677 case mf225:
2678 case mf226:
2679 case mf227:
2680 case mf228:
2681 case mf229:
2682 case mf230:
2683 case mf231:
2684 case mf232:
2685 case mf233:
2686 case mf234:
2687 case mf235:
2688 case mf236:
2689 case mf237:
2690 case mf238:
2691 case mf239:
2692 case mf240:
2693 case mf241:
2694 case mf242:
2695 case mf243:
2696 case mf244:
2697 case mf245:
2698 case mf246:
2699 case mf247:
2700 case mf248:
2701 case mf249:
2702 case mf250:
2703 case mf251:
2704 case mf252:
2705 case mf253:
2706 case mf254:
2707 case mfEXTENDED:
2708 break;
2709
2710 case mfPUSHUD:
2711 case mfPUSHLR:
2712 case mfPUSH4:
2713 case mfPUSHU:
2714 case mfPUSHD:
2715 case mfPUSHL:
2716 case mfPUSHR:
2717 case mfPUSHUDNS:
2718 case mfPUSHLRNS:
2719 case mfPUSH4NS:
2720 case mfPUSHUNS:
2721 case mfPUSHDNS:
2722 case mfPUSHLNS:
2723 case mfPUSHRNS:
2724 case mfPUSHUDINS:
2725 case mfPUSHLRINS:
2726 case mfPUSH4INS:
2727 case mfPUSHUINS:
2728 case mfPUSHDINS:
2729 case mfPUSHLINS:
2730 case mfPUSHRINS:
2731 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2732 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2733 {
2734 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2735 }
2736
2737 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2738 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2739 {
2740 if(hints)
2741 {
2742 switch(combobuf[tmpscr->data[i]].type)
2743 {
2744 case cPUSH_HEAVY:
2745 case cPUSH_HW:
2746 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2747 tempitemx=x, tempitemy=y;
2748
2749 if(tempitem>-1)
2750 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2751
2752 break;
2753
2754 case cPUSH_HEAVY2:
2755 case cPUSH_HW2:
2756 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2757 tempitemx=x, tempitemy=y;
2758
2759 if(tempitem>-1)
2760 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2761
2762 break;
2763 }
2764 }
2765 }
2766
2767 break;
2768
2769 case mfWHISTLE:
2770 if(hints)
2771 {
2772 tempitem=getItemID(itemsbuf,itype_whistle,1);
2773
2774 if(tempitem<0) break;
2775
2776 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2777 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2778 {
2779 tempitemx=x;
2780 tempitemy=y;
2781 }
2782
2783 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2784 }
2785
2786 break;
2787
2788 //Why is this here?
2789 case mfFAIRY:
2790 case mfMAGICFAIRY:
2791 case mfALLFAIRY:
2792 if(hints)
2793 {
2794 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2795
2796 if(tempitem < 0) break;
2797
2798 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2799 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2800 {
2801 tempitemx=x;
2802 tempitemy=y;
2803 }
2804
2805 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2806 }
2807
2808 break;
2809
2810 case mfBCANDLE:
2811 if(!hints)
2812 {
2813 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2814 }
2815 else
2816 {
2817 tempitem=getItemID(itemsbuf,itype_candle,1);
2818
2819 if(tempitem<0) break;
2820
2821 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2822 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2823 {
2824 tempitemx=x;
2825 tempitemy=y;
2826 }
2827
2828 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2829 }
2830
2831 break;
2832
2833 case mfRCANDLE:
2834 if(!hints)
2835 {
2836 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2837 }
2838 else
2839 {
2840 tempitem=getItemID(itemsbuf,itype_candle,2);
2841
2842 if(tempitem<0) break;
2843
2844 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2845 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2846 {
2847 tempitemx=x;
2848 tempitemy=y;
2849 }
2850
2851 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2852 }
2853
2854 break;
2855
2856 case mfWANDFIRE:
2857 if(!hints)
2858 {
2859 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2860 }
2861 else
2862 {
2863 tempitem=getItemID(itemsbuf,itype_wand,1);
2864
2865 if(tempitem<0) break;
2866
2867 tempweapon=wFire;
2868
2869 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2870 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2871 {
2872 tempitemx=x;
2873 tempitemy=y;
2874 }
2875 else
2876 {
2877 tempweaponx=x;
2878 tempweapony=y;
2879 }
2880
2881 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2882 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2883 }
2884
2885 break;
2886
2887 case mfDINSFIRE:
2888 if(!hints)
2889 {
2890 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDINSFIRE],tmpscr->secretcset[sDINSFIRE]);
2891 }
2892 else
2893 {
2894 tempitem=getItemID(itemsbuf,itype_dinsfire,1);
2895
2896 if(tempitem<0) break;
2897
2898 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2899 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2900 {
2901 tempitemx=x;
2902 tempitemy=y;
2903 }
2904
2905 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2906 }
2907
2908 break;
2909
2910 case mfARROW:
2911 if(!hints)
2912 {
2913 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2914 }
2915 else
2916 {
2917 tempitem=getItemID(itemsbuf,itype_arrow,1);
2918
2919 if(tempitem<0) break;
2920
2921 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2922 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2923 {
2924 tempitemx=x;
2925 tempitemy=y;
2926 }
2927
2928 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2929 }
2930
2931 break;
2932
2933 case mfSARROW:
2934 if(!hints)
2935 {
2936 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2937 }
2938 else
2939 {
2940 tempitem=getItemID(itemsbuf,itype_arrow,2);
2941
2942 if(tempitem<0) break;
2943
2944 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2945 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2946 {
2947 tempitemx=x;
2948 tempitemy=y;
2949 }
2950
2951 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2952 }
2953
2954 break;
2955
2956 case mfGARROW:
2957 if(!hints)
2958 {
2959 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
2960 }
2961 else
2962 {
2963 tempitem=getItemID(itemsbuf,itype_arrow,3);
2964
2965 if(tempitem<0) break;
2966
2967 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2968 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2969 {
2970 tempitemx=x;
2971 tempitemy=y;
2972 }
2973
2974 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2975 }
2976
2977 break;
2978
2979 case mfBOMB:
2980 if(!hints)
2981 {
2982 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
2983 }
2984 else
2985 {
2986 //tempitem=getItemID(itemsbuf,itype_bomb,1);
2987 tempweapon = wLitBomb;
2988
2989 //if (tempitem<0) break;
2990 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2991 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2992 {
2993 tempweaponx=x;
2994 tempweapony=y;
2995 }
2996
2997 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2998 }
2999
3000 break;
3001
3002 case mfSBOMB:
3003 if(!hints)
3004 {
3005 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3006 }
3007 else
3008 {
3009 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3010 //if (tempitem<0) break;
3011 tempweapon = wLitSBomb;
3012
3013 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3014 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3015 {
3016 tempweaponx=x;
3017 tempweapony=y;
3018 }
3019
3020 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3021 }
3022
3023 break;
3024
3025 case mfARMOS_SECRET:
3026 if(!hints)
3027 {
3028 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3029 }
3030 break;
3031
3032 case mfBRANG:
3033 if(!hints)
3034 {
3035 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3036 }
3037 else
3038 {
3039 tempitem=getItemID(itemsbuf,itype_brang,1);
3040
3041 if(tempitem<0) break;
3042
3043 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3044 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3045 {
3046 tempitemx=x;
3047 tempitemy=y;
3048 }
3049
3050 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3051 }
3052
3053 break;
3054
3055 case mfMBRANG:
3056 if(!hints)
3057 {
3058 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3059 }
3060 else
3061 {
3062 tempitem=getItemID(itemsbuf,itype_brang,2);
3063
3064 if(tempitem<0) break;
3065
3066 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3067 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3068 {
3069 tempitemx=x;
3070 tempitemy=y;
3071 }
3072
3073 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3074 }
3075
3076 break;
3077
3078 case mfFBRANG:
3079 if(!hints)
3080 {
3081 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3082 }
3083 else
3084 {
3085 tempitem=getItemID(itemsbuf,itype_brang,3);
3086
3087 if(tempitem<0) break;
3088
3089 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3090 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3091 {
3092 tempitemx=x;
3093 tempitemy=y;
3094 }
3095
3096 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3097 }
3098
3099 break;
3100
3101 case mfWANDMAGIC:
3102 if(!hints)
3103 {
3104 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3105 }
3106 else
3107 {
3108 tempitem=getItemID(itemsbuf,itype_wand,1);
3109
3110 if(tempitem<0) break;
3111
3112 tempweapon=itemsbuf[tempitem].wpn3;
3113
3114 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3115 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3116 {
3117 tempitemx=x;
3118 tempitemy=y;
3119 }
3120 else
3121 {
3122 tempweaponx=x;
3123 tempweapony=y;
3124 --lens_hint_weapon[wMagic][4];
3125
3126 if(lens_hint_weapon[wMagic][4]<-8)
3127 {
3128 lens_hint_weapon[wMagic][4]=8;
3129 }
3130 }
3131
3132 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3133 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3134 }
3135
3136 break;
3137
3138 case mfREFMAGIC:
3139 if(!hints)
3140 {
3141 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3142 }
3143 else
3144 {
3145 tempitem=getItemID(itemsbuf,itype_shield,3);
3146
3147 if(tempitem<0) break;
3148
3149 tempweapon=ewMagic;
3150
3151 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3152 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3153 {
3154 tempitemx=x;
3155 tempitemy=y;
3156 }
3157 else
3158 {
3159 tempweaponx=x;
3160 tempweapony=y;
3161
3162 if(lens_hint_weapon[ewMagic][2]==up)
3163 {
3164 --lens_hint_weapon[ewMagic][4];
3165 }
3166 else
3167 {
3168 ++lens_hint_weapon[ewMagic][4];
3169 }
3170
3171 if(lens_hint_weapon[ewMagic][4]>8)
3172 {
3173 lens_hint_weapon[ewMagic][2]=up;
3174 }
3175
3176 if(lens_hint_weapon[ewMagic][4]<=0)
3177 {
3178 lens_hint_weapon[ewMagic][2]=down;
3179 }
3180 }
3181
3182 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3183 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3184 }
3185
3186 break;
3187
3188 case mfREFFIREBALL:
3189 if(!hints)
3190 {
3191 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3192 }
3193 else
3194 {
3195 tempitem=getItemID(itemsbuf,itype_shield,3);
3196
3197 if(tempitem<0) break;
3198
3199 tempweapon=ewFireball;
3200
3201 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3202 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3203 {
3204 tempitemx=x;
3205 tempitemy=y;
3206 tempweaponx=x;
3207 tempweapony=y;
3208 ++lens_hint_weapon[ewFireball][3];
3209
3210 if(lens_hint_weapon[ewFireball][3]>8)
3211 {
3212 lens_hint_weapon[ewFireball][3]=-8;
3213 lens_hint_weapon[ewFireball][4]=8;
3214 }
3215
3216 if(lens_hint_weapon[ewFireball][3]>0)
3217 {
3218 ++lens_hint_weapon[ewFireball][4];
3219 }
3220 else
3221 {
3222 --lens_hint_weapon[ewFireball][4];
3223 }
3224 }
3225
3226 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3227 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3228 }
3229
3230 break;
3231
3232 case mfSWORD:
3233 if(!hints)
3234 {
3235 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3236 }
3237 else
3238 {
3239 tempitem=getItemID(itemsbuf,itype_sword,1);
3240
3241 if(tempitem<0) break;
3242
3243 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3244 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3245 {
3246 tempitemx=x;
3247 tempitemy=y;
3248 }
3249
3250 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3251 }
3252
3253 break;
3254
3255 case mfWSWORD:
3256 if(!hints)
3257 {
3258 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3259 }
3260 else
3261 {
3262 tempitem=getItemID(itemsbuf,itype_sword,2);
3263
3264 if(tempitem<0) break;
3265
3266 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3267 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3268 {
3269 tempitemx=x;
3270 tempitemy=y;
3271 }
3272
3273 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3274 }
3275
3276 break;
3277
3278 case mfMSWORD:
3279 if(!hints)
3280 {
3281 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3282 }
3283 else
3284 {
3285 tempitem=getItemID(itemsbuf,itype_sword,3);
3286
3287 if(tempitem<0) break;
3288
3289 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3290 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3291 {
3292 tempitemx=x;
3293 tempitemy=y;
3294 }
3295
3296 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3297 }
3298
3299 break;
3300
3301 case mfXSWORD:
3302 if(!hints)
3303 {
3304 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3305 }
3306 else
3307 {
3308 tempitem=getItemID(itemsbuf,itype_sword,4);
3309
3310 if(tempitem<0) break;
3311
3312 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3313 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3314 {
3315 tempitemx=x;
3316 tempitemy=y;
3317 }
3318
3319 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3320 }
3321
3322 break;
3323
3324 case mfSWORDBEAM:
3325 if(!hints)
3326 {
3327 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3328 }
3329 else
3330 {
3331 tempitem=getItemID(itemsbuf,itype_sword,1);
3332
3333 if(tempitem<0) break;
3334
3335 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3336 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3337 {
3338 tempitemx=x;
3339 tempitemy=y;
3340 }
3341
3342 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3343 }
3344
3345 break;
3346
3347 case mfWSWORDBEAM:
3348 if(!hints)
3349 {
3350 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3351 }
3352 else
3353 {
3354 tempitem=getItemID(itemsbuf,itype_sword,2);
3355
3356 if(tempitem<0) break;
3357
3358 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3359 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3360 {
3361 tempitemx=x;
3362 tempitemy=y;
3363 }
3364
3365 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3366 }
3367
3368 break;
3369
3370 case mfMSWORDBEAM:
3371 if(!hints)
3372 {
3373 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3374 }
3375 else
3376 {
3377 tempitem=getItemID(itemsbuf,itype_sword,3);
3378
3379 if(tempitem<0) break;
3380
3381 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3382 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3383 {
3384 tempitemx=x;
3385 tempitemy=y;
3386 }
3387
3388 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3389 }
3390
3391 break;
3392
3393 case mfXSWORDBEAM:
3394 if(!hints)
3395 {
3396 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3397 }
3398 else
3399 {
3400 tempitem=getItemID(itemsbuf,itype_sword,4);
3401
3402 if(tempitem<0) break;
3403
3404 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3405 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3406 {
3407 tempitemx=x;
3408 tempitemy=y;
3409 }
3410
3411 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3412 }
3413
3414 break;
3415
3416 case mfHOOKSHOT:
3417 if(!hints)
3418 {
3419 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3420 }
3421 else
3422 {
3423 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3424
3425 if(tempitem<0) break;
3426
3427 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3428 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3429 {
3430 tempitemx=x;
3431 tempitemy=y;
3432 }
3433
3434 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3435 }
3436
3437 break;
3438
3439 case mfWAND:
3440 if(!hints)
3441 {
3442 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3443 }
3444 else
3445 {
3446 tempitem=getItemID(itemsbuf,itype_wand,1);
3447
3448 if(tempitem<0) break;
3449
3450 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3451 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3452 {
3453 tempitemx=x;
3454 tempitemy=y;
3455 }
3456
3457 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3458 }
3459
3460 break;
3461
3462 case mfHAMMER:
3463 if(!hints)
3464 {
3465 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3466 }
3467 else
3468 {
3469 tempitem=getItemID(itemsbuf,itype_hammer,1);
3470
3471 if(tempitem<0) break;
3472
3473 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3474 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3475 {
3476 tempitemx=x;
3477 tempitemy=y;
3478 }
3479
3480 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3481 }
3482
3483 break;
3484
3485 case mfARMOS_ITEM:
3486 case mfDIVE_ITEM:
3487 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3488 {
3489 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3490 }
3491 break;
3492
3493 case 16:
3494 case 17:
3495 case 18:
3496 case 19:
3497 case 20:
3498 case 21:
3499 case 22:
3500 case 23:
3501 case 24:
3502 case 25:
3503 case 26:
3504 case 27:
3505 case 28:
3506 case 29:
3507 case 30:
3508 case 31:
3509 if(!hints)
3510 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3511 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3512
3513 break;
3514 case mfSECRETSNEXT:
3515 if(!hints)
3516 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3517 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3518
3519 break;
3520
3521 case mfSTRIKE:
3522 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3523 {
3524 goto special;
3525 }
3526 else
3527 {
3528 break;
3529 }
3530
3531 default: goto special;
3532
3533 special:
3534 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3535 {
3536 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3537 {
3538 rectfill(dest,x,y,x+15,y+15,WHITE);
3539 }
3540 }
3541
3542 break;
3543 }
3544 }
3545 }
3546
3547 if(layer)
3548 {
3549 if(tmpscr->door[0]==dWALK)
3550 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3551
3552 if(tmpscr->door[1]==dWALK)
3553 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3554
3555 if(tmpscr->door[2]==dWALK)
3556 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3557
3558 if(tmpscr->door[3]==dWALK)
3559 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3560
3561 if(tmpscr->door[0]==dBOMB)
3562 {
3563 showbombeddoor(dest, 0);
3564 }
3565
3566 if(tmpscr->door[1]==dBOMB)
3567 {
3568 showbombeddoor(dest, 1);
3569 }
3570
3571 if(tmpscr->door[2]==dBOMB)
3572 {
3573 showbombeddoor(dest, 2);
3574 }
3575
3576 if(tmpscr->door[3]==dBOMB)
3577 {
3578 showbombeddoor(dest, 3);
3579 }
3580 }
3581
3582 if(tmpscr->stairx + tmpscr->stairy)
3583 {
3584 if(!hints)
3585 {
3586 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3587 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3588 }
3589 else
3590 {
3591 if(tmpscr->flags&fWHISTLE)
3592 {
3593 tempitem=getItemID(itemsbuf,itype_whistle,1);
3594 int32_t tempitemx=-16;
3595 int32_t tempitemy=-16;
3596
3597 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3598 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3599 {
3600 tempitemx=tmpscr->stairx;
3601 tempitemy=tmpscr->stairy+playing_field_offset;
3602 }
3603
3604 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3605 }
3606 }
3607 }
3608 }
3609 }
3610
3611 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3612
3613 void draw_lens_over()
3614 {
3615 // Oh, what the heck.
3616 static BITMAP *lens_scr = NULL;
3617 static int32_t last_width = -1;
3618 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3619
3620 // Only redraw the circle if the size has changed
3621 if(width != last_width)
3622 {
3623 if(lens_scr == NULL)
3624 {
3625 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3626 }
3627
3628 clear_to_color(lens_scr, BLACK);
3629 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3630 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3631 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3632 last_width=width;
3633 }
3634
3635 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3636 }
3637
3638 //----------------------------------------------------------------
3639
3640 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3641 {
3642 //recreating a big bitmap every frame is highly sluggish.
3643 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3644 clear_to_color(wavebuf, BLACK);
3645 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3646
3647 int32_t ofs;
3648 // int32_t amplitude=8;
3649 // int32_t wavelength=4;
3650 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3651 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3652 int32_t amp2=168;
3653 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3654 int32_t i=frame%amp2;
3655
3656 for(int32_t j=0; j<168; j++)
3657 {
3658 if(j&1 && interpol)
3659 {
3660 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3661 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3662 }
3663 else
3664 {
3665 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3666 }
3667
3668 if(ofs)
3669 {
3670 for(int32_t k=0; k<256; k++)
3671 {
3672 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3673 }
3674 }
3675 }
3676 }
3677
3678 void draw_fuzzy(int32_t fuzz)
3679 // draws from right half of scrollbuf to framebuf
3680 {
3681 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3682 byte *start, *si, *di;
3683
3684 if(fuzz<1)
3685 fuzz = 1;
3686
3687 xstep = 128%fuzz;
3688
3689 if(xstep > 0)
3690 xstep = fuzz-xstep;
3691
3692 ystep = 112%fuzz;
3693
3694 if(ystep > 0)
3695 ystep = fuzz-ystep;
3696
3697 firsty = 1;
3698
3699 for(y=0; y<224;)
3700 {
3701 start = &(scrollbuf->line[y][256]);
3702
3703 for(dy=0; dy<ystep && dy+y<224; dy++)
3704 {
3705 si = start;
3706 di = &(framebuf->line[y+dy][0]);
3707 i = xstep;
3708 firstx = 1;
3709
3710 for(dx=0; dx<256; dx++)
3711 {
3712 *(di++) = *si;
3713
3714 if(++i >= fuzz)
3715 {
3716 if(!firstx)
3717 si += fuzz;
3718 else
3719 {
3720 si += fuzz-xstep;
3721 firstx = 0;
3722 }
3723
3724 i = 0;
3725 }
3726 }
3727 }
3728
3729 if(!firsty)
3730 y += fuzz;
3731 else
3732 {
3733 y += ystep;
3734 ystep = fuzz;
3735 firsty = 0;
3736 }
3737 }
3738 }
3739
3740 697240 void updatescr(bool allowwavy)
3741 {
3742
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 697231 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
697240 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3743
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 697231 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
697240 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3744
3745
1/2
✓ Branch 0 taken 697240 times.
✗ Branch 1 not taken.
697240 if(toogam)
3746 {
3747 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3748 }
3749
3750
1/2
✓ Branch 0 taken 697240 times.
✗ Branch 1 not taken.
697240 if(Showpal)
3751 dump_pal(framebuf);
3752
3753
2/2
✓ Branch 0 taken 691931 times.
✓ Branch 1 taken 5309 times.
697240 if(!Playing)
3754 5309 black_opening_count=0;
3755
3756
2/2
✓ Branch 0 taken 695260 times.
✓ Branch 1 taken 1980 times.
697240 if(black_opening_count<0) //shape is opening up
3757 {
3758 1980 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3759
3760
2/4
✓ Branch 0 taken 1980 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1980 times.
1980 if(Advance||(!Paused))
3761 {
3762 1980 ++black_opening_count;
3763 1980 }
3764 1980 }
3765
2/2
✓ Branch 0 taken 694732 times.
✓ Branch 1 taken 528 times.
695260 else if(black_opening_count>0) //shape is closing
3766 {
3767 528 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3768
3769
2/4
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528 times.
528 if(Advance||(!Paused))
3770 {
3771 528 --black_opening_count;
3772 528 }
3773 528 }
3774
3775
3/4
✓ Branch 0 taken 694770 times.
✓ Branch 1 taken 2470 times.
✓ Branch 2 taken 694770 times.
✗ Branch 3 not taken.
697240 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3776 {
3777 black_opening_shape = bosCIRCLE;
3778 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3779 refreshTints();
3780 refreshpal=true;
3781 }
3782
3783
2/2
✓ Branch 0 taken 690725 times.
✓ Branch 1 taken 6515 times.
697240 if(refreshpal)
3784 {
3785 6515 refreshpal=false;
3786 6515 RAMpal[253] = _RGB(0,0,0);
3787 6515 RAMpal[254] = _RGB(63,63,63);
3788 6515 hw_palette = &RAMpal;
3789 6515 update_hw_pal = true;
3790
3791 6515 create_rgb_table(&rgb_table, RAMpal, NULL);
3792 6515 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3793 6515 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3794
3795
2/2
✓ Branch 0 taken 1667840 times.
✓ Branch 1 taken 6515 times.
1674355 for(int32_t q=0; q<PAL_SIZE; q++)
3796 {
3797 1667840 trans_table2.data[0][q] = q;
3798 1667840 trans_table2.data[q][q] = q;
3799 1667840 }
3800 6515 }
3801
3802 697240 bool clearwavy = (wavy <= 0);
3803
3804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 697240 times.
697240 if(wavy <= 0)
3805 {
3806 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3807 697240 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3808 697240 }
3809
3810 697240 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3811
3812
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 697240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
697240 if(wavy && Playing && allowwavy)
3813 {
3814 draw_wavy(framebuf, wavybuf, wavy,false);
3815 }
3816
3817
1/2
✓ Branch 0 taken 697240 times.
✗ Branch 1 not taken.
697240 if(clearwavy)
3818 697240 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3819 else if(Playing && !Paused)
3820 wavy--; // Wavy was set by a script. Decrement it.
3821
3822
5/6
✓ Branch 0 taken 691931 times.
✓ Branch 1 taken 5309 times.
✓ Branch 2 taken 11574 times.
✓ Branch 3 taken 680357 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11574 times.
697240 if(Playing && msgpos && !screenscrolling)
3823 {
3824
1/2
✓ Branch 0 taken 11574 times.
✗ Branch 1 not taken.
11574 if(!(msg_bg_display_buf->clip))
3825 11574 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3826
1/2
✓ Branch 0 taken 11574 times.
✗ Branch 1 not taken.
11574 if(!(msg_portrait_display_buf->clip))
3827 11574 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3828
1/2
✓ Branch 0 taken 11574 times.
✗ Branch 1 not taken.
11574 if(!(msg_txt_display_buf->clip))
3829 11574 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3830 11574 }
3831
3832 /*
3833 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3834 {
3835 BITMAP* subBmp = 0;
3836 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3837 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3838 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3839 destroy_bitmap(subBmp);
3840 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3841 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3842 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3843 }
3844 */
3845
3846
1/2
✓ Branch 0 taken 697240 times.
✗ Branch 1 not taken.
697240 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3847
3848
1/2
✓ Branch 0 taken 697240 times.
✗ Branch 1 not taken.
697240 if(nosubscr)
3849 {
3850 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3851 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3852 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3853 }
3854
3855 //TODO: Optimize blit 'overcalls' -Gleeok
3856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 697240 times.
697240 BITMAP *source = nosubscr ? panorama : wavybuf;
3857 697240 blit(source,framebuf,0,0,0,0,256,224);
3858
3859 697240 update_hw_screen();
3860 697240 }
3861
3862 //----------------------------------------------------------------
3863
3864 PALETTE sys_pal;
3865
3866 int32_t onGUISnapshot()
3867 {
3868 char buf[200];
3869 int32_t num=0;
3870 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3871 do
3872 {
3873 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3874 }
3875 while(num<99999 && exists(buf));
3876
3877 BITMAP *b = create_bitmap_ex(8,resx,resy);
3878
3879 if(b)
3880 {
3881 if(MenuOpen)
3882 {
3883 //Cannot load game's palette while GUI elements are in focus. -Z
3884 //If there is a way to do this, then I have missed it.
3885 /*
3886 game_pal();
3887 RAMpal[253] = _RGB(0,0,0);
3888 RAMpal[254] = _RGB(63,63,63);
3889 set_palette_range(RAMpal,0,255,false);
3890 memcpy(RAMpal, snappal, sizeof(snappal));
3891 create_rgb_table(&rgb_table, RAMpal, NULL);
3892 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3893 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3894
3895 for(int32_t q=0; q<PAL_SIZE; q++)
3896 {
3897 trans_table2.data[0][q] = q;
3898 trans_table2.data[q][q] = q;
3899 }
3900 */
3901 //ringcolor(false);
3902 //get_palette(RAMpal);
3903 blit(screen,b,0,0,0,0,resx,resy);
3904 //al_trace("Menu Open\n");
3905 //game_pal();
3906 //PALETTE temppal;
3907 //get_palette(temppal);
3908 //system_pal();
3909 save_bitmap(buf,b,sys_pal);
3910 //save_bitmap(buf,b,RAMpal);
3911 //save_bitmap(buf,b,snappal);
3912 }
3913 else
3914 {
3915 blit(screen,b,0,0,0,0,resx,resy);
3916 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3917 }
3918 destroy_bitmap(b);
3919 }
3920
3921 return D_O_K;
3922 }
3923
3924 int32_t onNonGUISnapshot()
3925 {
3926 PALETTE temppal;
3927 get_palette(temppal);
3928 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3929
3930 char buf[200];
3931 int32_t num=0;
3932
3933 do
3934 {
3935 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3936 }
3937 while(num<99999 && exists(buf));
3938
3939 BITMAP *panorama = create_bitmap_ex(8,256,168);
3940 /*
3941 PALETTE tempRAMpal;
3942 get_palette(tempRAMpal);
3943
3944 if(tmpscr->flags3&fNOSUBSCR)
3945 {
3946 clear_to_color(panorama,0);
3947 blit(framebuf,panorama,0,playing_field_offset,0,0,256,168);
3948 save_bitmap(buf,panorama,realpal?temppal:tempRAMpal);
3949 }
3950 else
3951 {
3952 save_bitmap(buf,framebuf,realpal?temppal:tempRAMpal);
3953 }
3954
3955 destroy_bitmap(panorama);
3956 return D_O_K;
3957 */
3958 if(tmpscr->flags3&fNOSUBSCR && !(key[KEY_ALT]))
3959 {
3960 clear_to_color(panorama,0);
3961 blit(framebuf,panorama,0,playing_field_offset,0,0,256,168);
3962 save_bitmap(buf,panorama,realpal?temppal:RAMpal);
3963 }
3964 else
3965 {
3966 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3967 }
3968
3969 destroy_bitmap(panorama);
3970 return D_O_K;
3971 }
3972
3973 int32_t onSnapshot()
3974 {
3975 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3976 {
3977 onGUISnapshot();
3978 }
3979 else
3980 {
3981 onNonGUISnapshot();
3982 }
3983
3984 return D_O_K;
3985 }
3986
3987 int32_t onSaveMapPic()
3988 {
3989 int32_t mapres2 = 0;
3990 char buf[200];
3991 int32_t num=0;
3992 mapscr tmpscr_b[2];
3993 mapscr tmpscr_c[6];
3994 BITMAP* _screen_draw_buffer = NULL;
3995 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3996 set_clip_state(_screen_draw_buffer,1);
3997
3998 for(int32_t i=0; i<6; ++i)
3999 {
4000 tmpscr_c[i] = tmpscr2[i];
4001 tmpscr2[i].zero_memory();
4002
4003 if(i>=2)
4004 {
4005 continue;
4006 }
4007
4008 tmpscr_b[i] = tmpscr[i];
4009 tmpscr[i].zero_memory();
4010 }
4011
4012 do
4013 {
4014 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4015 }
4016 while(num<99999 && exists(buf));
4017
4018 BITMAP* mappic = NULL;
4019
4020
4021 bool done=false, redraw=true;
4022
4023 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4024
4025 if(!mappic)
4026 {
4027 system_pal();
4028 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4029 game_pal();
4030 return D_O_K;;
4031 }
4032
4033 // draw the map
4034 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4035
4036 for(int32_t y=0; y<8; y++)
4037 {
4038 for(int32_t x=0; x<16; x++)
4039 {
4040 if(!displayOnMap(x, y))
4041 {
4042 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4043 }
4044 else
4045 {
4046 int32_t s = (y<<4) + x;
4047 loadscr2(1,s,-1);
4048
4049 for(int32_t i=0; i<6; i++)
4050 {
4051 if(tmpscr[1].layermap[i]<=0)
4052 continue;
4053
4054 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4055 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4056 {
4057 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4058
4059 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4060 }
4061 }
4062
4063 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4064
4065 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4066
4067 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4068 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4069
4070 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4071
4072 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4073 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4074 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4075 {
4076 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4077 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4078 }
4079 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4080
4081 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4082
4083 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4084 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4085 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4086 {
4087 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4088 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4089 }
4090 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4091 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4092
4093 }
4094
4095 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4096 }
4097 }
4098
4099 for(int32_t i=0; i<6; ++i)
4100 {
4101 tmpscr2[i]=tmpscr_c[i];
4102
4103 if(i>=2)
4104 {
4105 continue;
4106 }
4107
4108 tmpscr[i]=tmpscr_b[i];
4109 }
4110
4111 save_bitmap(buf,mappic,RAMpal);
4112 destroy_bitmap(mappic);
4113 destroy_bitmap(_screen_draw_buffer);
4114 return D_O_K;
4115 }
4116
4117 /*
4118 int32_t onSaveMapPic()
4119 {
4120 BITMAP* mappic = NULL;
4121 BITMAP* _screen_draw_buffer = NULL;
4122 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4123 int32_t mapres2 = 0;
4124 char buf[20];
4125 int32_t num=0;
4126 set_clip_state(_screen_draw_buffer,1);
4127 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4128
4129 do
4130 {
4131 sprintf(buf, "zelda%03d.png", ++num);
4132 }
4133 while(num<999 && exists(buf));
4134
4135 // if(!mappic) {
4136 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4137
4138 if(!mappic)
4139 {
4140 system_pal();
4141 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4142 game_pal();
4143 return D_O_K;
4144 }
4145
4146 // }
4147
4148 int32_t layermap, layerscreen;
4149 int32_t x2=0;
4150
4151 // draw the map
4152 for(int32_t y=0; y<8; y++)
4153 {
4154 for(int32_t x=0; x<16; x++)
4155 {
4156 int32_t s = (y<<4) + x;
4157
4158 if(!displayOnMap(x, y))
4159 {
4160 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4161 }
4162 else
4163 {
4164 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4165 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4166
4167 for(int32_t k=0; k<4; k++)
4168 {
4169 if(k==2)
4170 {
4171 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4172 }
4173
4174 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4175
4176 if(layermap>-1)
4177 {
4178 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4179
4180 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4181 {
4182 for(int32_t i=0; i<176; i++)
4183 {
4184 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4185 }
4186 }
4187 else
4188 {
4189 for(int32_t i=0; i<176; i++)
4190 {
4191 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4192 }
4193 }
4194 }
4195 }
4196
4197 for(int32_t i=0; i<176; i++)
4198 {
4199 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4200 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4201 {
4202 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4203 }
4204 }
4205
4206 for(int32_t k=4; k<6; k++)
4207 {
4208 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4209
4210 if(layermap>-1)
4211 {
4212 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4213
4214 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4215 {
4216 for(int32_t i=0; i<176; i++)
4217 {
4218 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4219 }
4220 }
4221 else
4222 {
4223 for(int32_t i=0; i<176; i++)
4224 {
4225 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4226 }
4227 }
4228 }
4229 }
4230 }
4231
4232 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4233 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4234 }
4235
4236 }
4237
4238 save_bitmap(buf,mappic,RAMpal);
4239 destroy_bitmap(mappic);
4240 destroy_bitmap(_screen_draw_buffer);
4241 return D_O_K;
4242 }
4243 */
4244
4245 1 void f_Quit(int32_t type)
4246 {
4247
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(type==qQUIT && !Playing)
4248 return;
4249
4250 1 bool from_menu = is_sys_pal;
4251
4252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!from_menu)
4253 {
4254 1 music_pause();
4255 1 pause_all_sfx();
4256 1 }
4257 1 enter_sys_pal();
4258 1 clear_keybuf();
4259
4260 1 replay_poll();
4261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (replay_is_replaying())
4262 1 replay_peek_quit();
4263
4264
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!replay_is_replaying())
4265 switch(type)
4266 {
4267 case qQUIT:
4268 onQuit();
4269 break;
4270
4271 case qRESET:
4272 onReset();
4273 break;
4274
4275 case qEXIT:
4276 onExit();
4277 break;
4278 }
4279
4280
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(Quit)
4281 {
4282 1 kill_sfx();
4283 1 music_stop();
4284 1 exit_sys_pal();
4285 1 update_hw_screen();
4286 1 }
4287 else
4288 {
4289 exit_sys_pal();
4290 if(!from_menu)
4291 {
4292 music_resume();
4293 resume_all_sfx();
4294 }
4295 }
4296
4297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!from_menu)
4298 1 show_mouse(NULL);
4299 1 eat_buttons();
4300
4301 1 zc_readrawkey(KEY_ESC);
4302
4303 1 zc_readrawkey(KEY_ENTER);
4304 1 }
4305
4306 //----------------------------------------------------------------
4307
4308 int32_t onNoWalls()
4309 {
4310 cheats_enqueue(Cheat::Walls);
4311 return D_O_K;
4312 }
4313
4314 int32_t onIgnoreSideview()
4315 {
4316 cheats_enqueue(Cheat::IgnoreSideView);
4317 return D_O_K;
4318 }
4319
4320 710160 int32_t input_idle(bool checkmouse)
4321 {
4322 static int32_t mx, my, mz, mb;
4323
4324
4/6
✓ Branch 0 taken 710160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102888 times.
✓ Branch 3 taken 607272 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 102888 times.
813048 if(keypressed() || zc_key_pressed() ||
4325
4/8
✓ Branch 0 taken 102888 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102888 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 102888 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 102888 times.
✗ Branch 7 not taken.
102888 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4326 {
4327 607272 idle_count = 0;
4328
4329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 607272 times.
607272 if(active_count < MAX_ACTIVE)
4330 {
4331 607272 ++active_count;
4332 607272 }
4333 607272 }
4334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102888 times.
102888 else if(idle_count < MAX_IDLE)
4335 {
4336 102888 ++idle_count;
4337 102888 active_count = 0;
4338 102888 }
4339
4340 710160 mx = mouse_x;
4341 710160 my = mouse_y;
4342 710160 mz = mouse_z;
4343 710160 mb = mouse_b;
4344
4345 710160 return idle_count;
4346 }
4347
4348 int32_t onGoFast()
4349 {
4350 cheats_enqueue(Cheat::Fast);
4351 return D_O_K;
4352 }
4353
4354 int32_t onKillCheat()
4355 {
4356 cheats_enqueue(Cheat::Kill);
4357 return D_O_K;
4358 }
4359
4360 int32_t onShowLayer0()
4361 {
4362 show_layer_0 = !show_layer_0;
4363 return D_O_K;
4364 }
4365 int32_t onShowLayer1()
4366 {
4367 show_layer_1 = !show_layer_1;
4368 return D_O_K;
4369 }
4370 int32_t onShowLayer2()
4371 {
4372 show_layer_2 = !show_layer_2;
4373 return D_O_K;
4374 }
4375 int32_t onShowLayer3()
4376 {
4377 show_layer_3 = !show_layer_3;
4378 return D_O_K;
4379 }
4380 int32_t onShowLayer4()
4381 {
4382 show_layer_4 = !show_layer_4;
4383 return D_O_K;
4384 }
4385 int32_t onShowLayer5()
4386 {
4387 show_layer_5 = !show_layer_5;
4388 return D_O_K;
4389 }
4390 int32_t onShowLayer6()
4391 {
4392 show_layer_6 = !show_layer_6;
4393 return D_O_K;
4394 }
4395 int32_t onShowLayerO()
4396 {
4397 show_layer_over=!show_layer_over;
4398 return D_O_K;
4399 }
4400 int32_t onShowLayerP()
4401 {
4402 show_layer_push=!show_layer_push;
4403 return D_O_K;
4404 }
4405 int32_t onShowLayerS()
4406 {
4407 show_sprites=!show_sprites;
4408 return D_O_K;
4409 }
4410 int32_t onShowLayerF()
4411 {
4412 show_ffcs=!show_ffcs;
4413 return D_O_K;
4414 }
4415 int32_t onShowLayerW()
4416 {
4417 show_walkflags=!show_walkflags;
4418 return D_O_K;
4419 }
4420 int32_t onShowLayerE()
4421 {
4422 show_effectflags=!show_effectflags;
4423 return D_O_K;
4424 }
4425 int32_t onShowFFScripts()
4426 {
4427 show_ff_scripts=!show_ff_scripts;
4428 return D_O_K;
4429 }
4430 int32_t onShowHitboxes()
4431 {
4432 show_hitboxes=!show_hitboxes;
4433 return D_O_K;
4434 }
4435
4436 int32_t onLightSwitch()
4437 {
4438 cheats_enqueue(Cheat::Light);
4439 return D_O_K;
4440 }
4441
4442 int32_t onGoTo();
4443 int32_t onGoToComplete();
4444
4445 710160 void syskeys()
4446 {
4447 710160 update_system_keys();
4448
4449 int32_t oldtitle_version;
4450
4451
1/2
✓ Branch 0 taken 710160 times.
✗ Branch 1 not taken.
710160 if(close_button_quit)
4452 {
4453 close_button_quit=false;
4454 f_Quit(qEXIT);
4455 }
4456
4457 710160 poll_joystick();
4458
4459
2/10
✓ Branch 0 taken 710160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 710160 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
710160 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4460 {
4461 oldtitle_version=title_version;
4462 System();
4463 }
4464
4465 710160 mouse_down=gui_mouse_b();
4466
4467
1/2
✓ Branch 0 taken 710160 times.
✗ Branch 1 not taken.
710160 if(zc_read_system_key(KEY_F1))
4468 {
4469 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4470 {
4471 halt=!halt;
4472 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4473 }
4474 else
4475 {
4476 Throttlefps=!Throttlefps;
4477 logic_counter=0;
4478 }
4479 }
4480
4481 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4482 /*
4483 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4484 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4485 */
4486
4487
1/4
✓ Branch 0 taken 710160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
710160 if(zc_read_system_key(KEY_OPENBRACE)) if(frame_rest_suggest > 0) frame_rest_suggest--;
4488
4489
1/4
✓ Branch 0 taken 710160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
710160 if(zc_read_system_key(KEY_CLOSEBRACE)) if(frame_rest_suggest <= 2) frame_rest_suggest++;
4490
4491
1/2
✓ Branch 0 taken 710160 times.
✗ Branch 1 not taken.
710160 if(zc_read_system_key(KEY_F2)) ShowFPS=!ShowFPS;
4492
4493
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 710160 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
710160 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4494
4495
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 710160 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
710160 if(zc_read_system_key(KEY_F4) && Playing)
4496 {
4497 Paused=true;
4498 Advance=true;
4499 }
4500
4501
1/2
✓ Branch 0 taken 710160 times.
✗ Branch 1 not taken.
710160 if(zc_read_system_key(KEY_F6)) onTryQuit();
4502
4503 #ifndef ALLEGRO_MACOSX
4504 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4505
4506 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4507 #else
4508
1/2
✓ Branch 0 taken 710160 times.
✗ Branch 1 not taken.
710160 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4509
4510
1/2
✓ Branch 0 taken 710160 times.
✗ Branch 1 not taken.
710160 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4511 #endif
4512
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 710160 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
710160 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4513
4514
1/2
✓ Branch 0 taken 710160 times.
✗ Branch 1 not taken.
710160 if (zc_read_system_key(KEY_F12))
4515 {
4516 onSnapshot();
4517 }
4518
4519
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 710160 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
710160 if(debug_enabled && zc_read_system_key(KEY_TAB))
4520 set_debug(!get_debug());
4521
4522
3/4
✓ Branch 0 taken 710160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13843 times.
✓ Branch 3 taken 696317 times.
710160 if(get_debug() || cheat>=1)
4523 {
4524
1/2
✓ Branch 0 taken 13843 times.
✗ Branch 1 not taken.
13843 if( CheatModifierKeys() )
4525 {
4526 if(zc_readkey(KEY_ASTERISK) || zc_readkey(KEY_H)) cheats_enqueue(Cheat::Life, game->get_maxlife());
4527
4528 if(zc_readkey(KEY_SLASH_PAD) || zc_readkey(KEY_M)) cheats_enqueue(Cheat::Magic, game->get_maxmagic());
4529
4530 if(zc_readkey(KEY_R)) cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
4531
4532 if(zc_readkey(KEY_B))
4533 {
4534 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
4535 }
4536
4537 if(zc_readkey(KEY_A))
4538 {
4539 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
4540 }
4541 }
4542 13843 }
4543
4544
3/4
✓ Branch 0 taken 710160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13843 times.
✓ Branch 3 taken 696317 times.
710160 if(get_debug() || cheat>=2)
4545 {
4546
1/2
✓ Branch 0 taken 13843 times.
✗ Branch 1 not taken.
13843 if( CheatModifierKeys() )
4547 {
4548 if(rI())
4549 {
4550 cheats_enqueue(Cheat::Clock);
4551 }
4552 }
4553 13843 }
4554
4555
3/4
✓ Branch 0 taken 710160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13843 times.
✓ Branch 3 taken 696317 times.
710160 if(get_debug() || cheat>=4)
4556 {
4557
1/2
✓ Branch 0 taken 13843 times.
✗ Branch 1 not taken.
13843 if( CheatModifierKeys() )
4558 {
4559 if(rF11())
4560 {
4561 cheats_enqueue(Cheat::Walls);
4562 }
4563
4564 if(rQ())
4565 {
4566 cheats_enqueue(Cheat::Fast);
4567 }
4568
4569 if(zc_readkey(KEY_F))
4570 {
4571 cheats_enqueue(Cheat::Freeze);
4572 }
4573
4574 if(zc_readkey(KEY_G)) onGoToComplete();
4575
4576 if(zc_readkey(KEY_0)) onShowLayer0();
4577
4578 if(zc_readkey(KEY_1)) onShowLayer1();
4579
4580 if(zc_readkey(KEY_2)) onShowLayer2();
4581
4582 if(zc_readkey(KEY_3)) onShowLayer3();
4583
4584 if(zc_readkey(KEY_4)) onShowLayer4();
4585
4586 if(zc_readkey(KEY_5)) onShowLayer5();
4587
4588 if(zc_readkey(KEY_6)) onShowLayer6();
4589
4590 //if(zc_readkey(KEY_7)) onShowLayerO();
4591 if(zc_readkey(KEY_7)) onShowLayerF();
4592
4593 if(zc_readkey(KEY_8)) onShowLayerS();
4594
4595 if(zc_readkey(KEY_W)) onShowLayerW();
4596
4597 if(zc_readkey(KEY_L)) cheats_enqueue(Cheat::Light);
4598
4599 if(zc_readkey(KEY_V)) cheats_enqueue(Cheat::IgnoreSideView);
4600
4601 if(zc_readkey(KEY_K)) cheats_enqueue(Cheat::Kill);
4602 if(zc_readkey(KEY_O)) onShowLayerO();
4603 if(zc_readkey(KEY_P)) onShowLayerP();
4604 if(zc_readkey(KEY_C)) onShowHitboxes();
4605 if(zc_readkey(KEY_F)) onShowFFScripts();
4606 }
4607 13843 }
4608
4609
1/2
✓ Branch 0 taken 710160 times.
✗ Branch 1 not taken.
710160 if(volkeys)
4610 {
4611 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4612
4613 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4614
4615 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4616
4617 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4618 }
4619
4620
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 710160 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
710160 if(!get_debug() || !SystemKeys || replay_is_replaying())
4621 710160 goto bottom;
4622
4623 if(zc_readkey(KEY_D))
4624 {
4625 details = !details;
4626 rectfill(screen,0,0,319,7,BLACK);
4627 rectfill(screen,0,8,31,239,BLACK);
4628 rectfill(screen,288,8,319,239,BLACK);
4629 rectfill(screen,32,232,287,239,BLACK);
4630 }
4631
4632 if(zc_readkey(KEY_P)) Paused=!Paused;
4633
4634 //if(zc_readkey(KEY_P)) centerHero();
4635 if(zc_readkey(KEY_A))
4636 {
4637 Paused=true;
4638 Advance=true;
4639 }
4640
4641 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4642 #ifndef ALLEGRO_MACOSX
4643 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4644
4645 if(zc_readkey(KEY_F7))
4646 {
4647 Matrix(ss_speed, ss_density, 0);
4648 game_pal();
4649 }
4650 #else
4651 // The reason these are different on Mac in the first place is that
4652 // the OS doesn't let us use F9 and F10...
4653 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4654
4655 if(zc_readkey(KEY_F9))
4656 {
4657 Matrix(ss_speed, ss_density, 0);
4658 game_pal();
4659 }
4660 #endif
4661 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4662 {
4663 //change containers
4664 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4665 {
4666 //magic containers
4667 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4668 {
4669 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4670 }
4671 else
4672 {
4673 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4674 }
4675 }
4676 else
4677 {
4678 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4679 {
4680 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4681 }
4682 else
4683 {
4684 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4685 }
4686 }
4687 }
4688
4689 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4690 {
4691 //change containers
4692 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4693 {
4694 //magic containers
4695 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4696 {
4697 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4698 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4699 //heart containers
4700 }
4701 else
4702 {
4703 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4704 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4705 }
4706 }
4707 else
4708 {
4709 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4710 {
4711 game->set_magic(zc_max(game->get_magic()-1,0));
4712 }
4713 else
4714 {
4715 game->set_life(zc_max(game->get_life()-1,0));
4716 }
4717 }
4718 }
4719
4720 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4721
4722 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4723
4724 verifyBothWeapons();
4725
4726 bottom:
4727
4728
1/2
✓ Branch 0 taken 710160 times.
✗ Branch 1 not taken.
710160 if(input_idle(true) > after_time())
4729 {
4730 Matrix(ss_speed, ss_density, 0);
4731 game_pal();
4732 }
4733 //Saffith's method of separating system and game key bindings. Can't do this!!
4734 //restoreInput(); //This caused input to become randomly 'stuck'. -Z
4735
4736 //while(Playing && keypressed())
4737 //readkey();
4738 // What's the Playing check for?
4739 710160 clear_keybuf();
4740 710160 }
4741
4742 62414 void checkQuitKeys()
4743 {
4744 #ifndef ALLEGRO_MACOSX
4745 if(zc_readrawkey(KEY_F9)) f_Quit(qRESET);
4746
4747 if(zc_readrawkey(KEY_F10)) f_Quit(qEXIT);
4748 #else
4749
1/2
✓ Branch 0 taken 62414 times.
✗ Branch 1 not taken.
62414 if(zc_readrawkey(KEY_F7)) f_Quit(qRESET);
4750
4751
1/2
✓ Branch 0 taken 62414 times.
✗ Branch 1 not taken.
62414 if(zc_readrawkey(KEY_F8)) f_Quit(qEXIT);
4752 #endif
4753 62414 }
4754
4755 41529 bool CheatModifierKeys()
4756 {
4757 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4758 // to trigger cheats.
4759
1/2
✓ Branch 0 taken 41529 times.
✗ Branch 1 not taken.
41529 if (replay_is_replaying())
4760 41529 return false;
4761
4762 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4763 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4764 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4765 {
4766 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4767 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4768 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4769 {
4770 return true;
4771 }
4772 }
4773 return false;
4774 41529 }
4775
4776 //99:05:54, for some reason?
4777 #define OLDMAXTIME 21405240
4778 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4779 #define MAXTIME 1944000000
4780
4781 697247 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4782 {
4783
2/2
✓ Branch 0 taken 463409 times.
✓ Branch 1 taken 233838 times.
697247 if(zcmusic!=NULL)
4784 {
4785 233838 zcmusic_poll();
4786 233838 }
4787
4788
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 697247 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 697247 times.
697247 while(Paused && !Advance && !Quit)
4789 {
4790 // have to call this, otherwise we'll get an infinite loop
4791 syskeys();
4792 if(allowF6Script)
4793 {
4794 FFCore.runF6Engine();
4795 }
4796 if (replay_get_mode() != ReplayMode::Assert)
4797 updatescr(allowwavy);
4798 throttleFPS();
4799
4800 #ifdef _WIN32
4801
4802 if(use_dwm_flush)
4803 {
4804 do_DwmFlush();
4805 }
4806
4807 #endif
4808
4809 // to keep music playing
4810 if(zcmusic!=NULL)
4811 {
4812 zcmusic_poll();
4813 }
4814 }
4815
4816
2/2
✓ Branch 0 taken 697240 times.
✓ Branch 1 taken 7 times.
697247 if(Quit)
4817 7 return;
4818
4819
3/4
✓ Branch 0 taken 691931 times.
✓ Branch 1 taken 5309 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 691931 times.
697240 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4820 691931 game->change_time(1);
4821
4822 697240 Advance=false;
4823
4824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 697240 times.
697240 if (replay_is_active())
4825 {
4826
2/2
✓ Branch 0 taken 652532 times.
✓ Branch 1 taken 44708 times.
697240 if (replay_get_version() >= 3)
4827 44708 replay_poll();
4828
2/2
✓ Branch 0 taken 686487 times.
✓ Branch 1 taken 10753 times.
697240 if (replay_get_version() >= 6)
4829 10753 replay_peek_input();
4830 697240 }
4831 697240 update_keys();
4832
4833 697240 ++frame;
4834
4835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 697240 times.
697240 if (replay_is_replaying())
4836 697240 replay_do_cheats();
4837 697240 syskeys();
4838
4839 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4840 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4841 // approach here means it doesn't matter which call adds the cheat.
4842 697240 cheats_execute_queued();
4843
4844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 697240 times.
697240 if (replay_is_replaying())
4845 697240 replay_peek_quit();
4846
2/2
✓ Branch 0 taken 697239 times.
✓ Branch 1 taken 1 times.
697240 if (GameFlags & GAMEFLAG_TRYQUIT)
4847 1 replay_step_quit(0);
4848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 697240 times.
697240 if(allowF6Script)
4849 {
4850 697240 FFCore.runF6Engine();
4851 697240 }
4852
2/2
✓ Branch 0 taken 697215 times.
✓ Branch 1 taken 25 times.
697240 if (Quit)
4853 25 replay_step_quit(Quit);
4854 // Someday... maybe install a Turbo button here?
4855 697240 updatescr(allowwavy);
4856 697240 throttleFPS();
4857
4858 #ifdef _WIN32
4859
4860 if(use_dwm_flush)
4861 {
4862 do_DwmFlush();
4863 }
4864
4865 #endif
4866
4867 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 697240 times.
697240 if(sfxcleanup)
4869 697240 sfx_cleanup();
4870 697247 }
4871
4872 void zapout()
4873 {
4874 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4875 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4876
4877 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4878 script_drawing_commands.Clear();
4879
4880 // zap out
4881 for(int32_t i=1; i<=24; i++)
4882 {
4883 draw_fuzzy(i);
4884 syskeys();
4885 advanceframe(true);
4886
4887 if(Quit)
4888 {
4889 break;
4890 }
4891 }
4892 }
4893
4894 void zapin()
4895 {
4896 FFCore.warpScriptCheck();
4897 draw_screen(tmpscr);
4898 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4899 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4900 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4901
4902 // zap out
4903 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4904 for(int32_t i=24; i>=1; i--)
4905 {
4906 draw_fuzzy(i);
4907 syskeys();
4908 advanceframe(true);
4909
4910 if(Quit)
4911 {
4912 break;
4913 }
4914 }
4915 }
4916
4917
4918 void wavyout(bool showhero)
4919 {
4920 draw_screen(tmpscr, showhero);
4921 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4922
4923 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4924 clear_to_color(wavebuf,0);
4925 blit(framebuf,wavebuf,0,0,16,0,256,224);
4926
4927 static PALETTE wavepal;
4928
4929 int32_t ofs;
4930 int32_t amplitude=8;
4931
4932 int32_t wavelength=4;
4933 double palpos=0, palstep=4, palstop=126;
4934
4935 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4936 for(int32_t i=0; i<168; i+=wavelength)
4937 {
4938 for(int32_t l=0; l<256; l++)
4939 {
4940 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4941 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4942 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4943 }
4944
4945 palpos+=palstep;
4946
4947 if(palpos>=0)
4948 {
4949 hw_palette = &wavepal;
4950 update_hw_pal = true;
4951 }
4952 else
4953 {
4954 hw_palette = &RAMpal;
4955 update_hw_pal = true;
4956 }
4957
4958 for(int32_t j=0; j+playing_field_offset<224; j++)
4959 {
4960 for(int32_t k=0; k<256; k++)
4961 {
4962 ofs=0;
4963
4964 if((j<i)&&(j&1))
4965 {
4966 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4967 }
4968
4969 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4970 }
4971 }
4972
4973 syskeys();
4974 advanceframe(true);
4975
4976 // animate_combos();
4977 if(Quit)
4978 break;
4979 }
4980
4981 destroy_bitmap(wavebuf);
4982 }
4983
4984 void wavyin()
4985 {
4986 draw_screen(tmpscr);
4987 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4988
4989 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4990 clear_to_color(wavebuf,0);
4991 blit(framebuf,wavebuf,0,0,16,0,256,224);
4992
4993 static PALETTE wavepal;
4994
4995 //Breaks dark rooms.
4996 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4997 /*
4998 loadfullpal();
4999 loadlvlpal(DMaps[currdmap].color);
5000 ringcolor(false);
5001 */
5002 refreshpal=false;
5003 int32_t ofs;
5004 int32_t amplitude=8;
5005 int32_t wavelength=4;
5006 double palpos=168, palstep=4, palstop=126;
5007
5008 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
5009 for(int32_t i=0; i<168; i+=wavelength)
5010 {
5011 for(int32_t l=0; l<256; l++)
5012 {
5013 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
5014 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
5015 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
5016 }
5017
5018 palpos-=palstep;
5019
5020 if(palpos>=0)
5021 {
5022 hw_palette = &wavepal;
5023 update_hw_pal = true;
5024 }
5025 else
5026 {
5027 hw_palette = &RAMpal;
5028 update_hw_pal = true;
5029 }
5030
5031 for(int32_t j=0; j+playing_field_offset<224; j++)
5032 {
5033 for(int32_t k=0; k<256; k++)
5034 {
5035 ofs=0;
5036
5037 if((j<(167-i))&&(j&1))
5038 {
5039 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
5040 }
5041
5042 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
5043 }
5044 }
5045
5046 syskeys();
5047 advanceframe(true);
5048 // animate_combos();
5049
5050 if(Quit)
5051 break;
5052 }
5053
5054 destroy_bitmap(wavebuf);
5055 }
5056
5057 237 void blackscr(int32_t fcnt,bool showsubscr)
5058 {
5059 237 reset_pal_cycling();
5060 237 script_drawing_commands.Clear();
5061
5062 237 FFCore.warpScriptCheck();
5063 237 bool showtime = game->should_show_time();
5064
2/2
✓ Branch 0 taken 237 times.
✓ Branch 1 taken 7110 times.
7347 while(fcnt>0)
5065 {
5066 7110 clear_bitmap(framebuf);
5067
5068
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 5580 times.
7110 if(showsubscr)
5069 {
5070 5580 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
5071
3/4
✓ Branch 0 taken 5580 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 5550 times.
5580 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
5072 {
5073 30 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
5074 30 }
5075 5580 }
5076
5077 7110 syskeys();
5078 7110 advanceframe(true);
5079
5080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7110 times.
7110 if(Quit)
5081 break;
5082
5083 7110 --fcnt;
5084 }
5085 237 }
5086
5087 77 void openscreen(int32_t shape)
5088 {
5089 77 reset_pal_cycling();
5090 77 black_opening_count=0;
5091
5092
3/4
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 52 times.
77 if(COOLSCROLL || shape>-1)
5093 {
5094 25 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5095 25 return;
5096 }
5097 else
5098 {
5099 52 Hero.setDontDraw(true);
5100 52 show_subscreen_dmap_dots=false;
5101 52 show_subscreen_numbers=false;
5102 // show_subscreen_items=false;
5103 52 show_subscreen_life=false;
5104 }
5105
5106 52 int32_t x=128;
5107
5108 52 FFCore.warpScriptCheck();
5109
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 4160 times.
4212 for(int32_t i=0; i<80; i++)
5110 {
5111 4160 draw_screen(tmpscr);
5112 //? draw_screen already draws the subscreen -DD
5113 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5114 4160 x=128-(((i*128/80)/8)*8);
5115
5116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4160 times.
4160 if(x>0)
5117 {
5118 4160 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5119 4160 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5120 4160 }
5121
5122 // x=((80-i)/2)*4;
5123 /*
5124 --x;
5125 switch(++c)
5126 {
5127 case 5: c=0;
5128 case 0:
5129 case 2:
5130 case 3: --x; break;
5131 }
5132 */
5133 4160 syskeys();
5134 4160 advanceframe(true);
5135
5136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4160 times.
4160 if(Quit)
5137 {
5138 break;
5139 }
5140 4160 }
5141
5142 52 Hero.setDontDraw(false);
5143 52 show_subscreen_items=true;
5144 52 show_subscreen_dmap_dots=true;
5145 77 }
5146
5147 void closescreen(int32_t shape)
5148 {
5149 reset_pal_cycling();
5150 black_opening_count=0;
5151
5152 if(COOLSCROLL || shape>-1)
5153 {
5154 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5155 return;
5156 }
5157 else
5158 {
5159 Hero.setDontDraw(true);
5160 show_subscreen_dmap_dots=false;
5161 show_subscreen_numbers=false;
5162 // show_subscreen_items=false;
5163 show_subscreen_life=false;
5164 }
5165
5166 int32_t x=128;
5167
5168 FFCore.warpScriptCheck();
5169 for(int32_t i=79; i>=0; --i)
5170 {
5171 draw_screen(tmpscr);
5172 //? draw_screen already draws the subscreen -DD
5173 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5174 x=128-(((i*128/80)/8)*8);
5175
5176 if(x>0)
5177 {
5178 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5179 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5180 }
5181
5182 // x=((80-i)/2)*4;
5183 /*
5184 --x;
5185 switch(++c)
5186 {
5187 case 5: c=0;
5188 case 0:
5189 case 2:
5190 case 3: --x; break;
5191 }
5192 */
5193 syskeys();
5194 advanceframe(true);
5195
5196 if(Quit)
5197 {
5198 break;
5199 }
5200 }
5201
5202 Hero.setDontDraw(false);
5203 show_subscreen_items=true;
5204 show_subscreen_dmap_dots=true;
5205 }
5206
5207 4 int32_t TriforceCount()
5208 {
5209 4 int32_t c=0;
5210
5211
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4 times.
36 for(int32_t i=1; i<=8; i++)
5212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
64 if(game->lvlitems[i]&liTRIFORCE)
5213 32 ++c;
5214
5215 4 return c;
5216 }
5217
5218 int32_t onCustomGame()
5219 {
5220 int32_t file = getsaveslot();
5221
5222 if(file < 0)
5223 return D_O_K;
5224
5225 bool ret = (custom_game(file)!=0);
5226 return ret ? D_CLOSE : D_O_K;
5227 }
5228
5229 int32_t onContinue()
5230 {
5231 return D_CLOSE;
5232 }
5233
5234 int32_t onEsc() // Unused?? -L
5235 {
5236 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5237 }
5238
5239 int32_t onVsync()
5240 {
5241 Throttlefps = !Throttlefps;
5242 save_game_configs();
5243 return D_O_K;
5244 }
5245
5246 int32_t onWinPosSave()
5247 {
5248 SaveWinPos = !SaveWinPos;
5249 return D_O_K;
5250 }
5251
5252 int32_t onClickToFreeze()
5253 {
5254 ClickToFreeze = !ClickToFreeze;
5255 save_game_configs();
5256 return D_O_K;
5257 }
5258
5259 int32_t OnSaveZCConfig()
5260 {
5261 if(jwin_alert3(
5262 "Save Configuration",
5263 "Are you sure that you wish to save your present configuration settings?",
5264 "This will overwrite your prior settings!",
5265 NULL,
5266 "&Yes",
5267 "&No",
5268 NULL,
5269 'y',
5270 'n',
5271 0,
5272 lfont) == 1)
5273 {
5274 save_game_configs();
5275 return D_O_K;
5276 }
5277 else return D_O_K;
5278 }
5279
5280 int32_t OnnClearQuestDir()
5281 {
5282 if(jwin_alert3(
5283 "Clear Current Directory Cache",
5284 "Are you sure that you wish to clear the current cached directory?",
5285 "This will default the current directory to the ROOT for this instance of ZC Player!",
5286 NULL,
5287 "&Yes",
5288 "&No",
5289 NULL,
5290 'y',
5291 'n',
5292 0,
5293 lfont) == 1)
5294 {
5295 set_config_string("zeldadx","win_qst_dir","");
5296 flush_config_file();
5297 strcpy(qstdir,get_config_string("zeldadx","win_qst_dir",""));
5298 //strcpy(filepath,get_config_string("zeldadx","win_qst_dir",""));
5299 save_game_configs();
5300 #ifdef __EMSCRIPTEN__
5301 em_sync_fs();
5302 #endif
5303 return D_O_K;
5304 }
5305 else return D_O_K;
5306 }
5307
5308
5309 int32_t onConsoleZASM()
5310 {
5311 if ( !zasm_debugger )
5312 {
5313 AlertDialog("WARNING: ZASM Debugger",
5314 "Enabling this will open the ZASM Debugger Console"
5315 "\nThis will likely grind ZC to a halt with lag."
5316 "\nTo make any use of this, it is suggested that you read"
5317 "\nthe documentation for 'void Breakpoint(char[] string);'"
5318 " in 'ZScript_Additions.txt'"
5319 "\nThis is not recommended for normal users,"
5320 " and is only intended for ZC developers,"
5321 "\nor quest developers coding directly in ZASM"
5322 "\nAre you sure that you wish to open the ZASM Debugger?",
5323 [&](bool ret,bool)
5324 {
5325 if(ret)
5326 {
5327 FFCore.ZASMPrint(true);
5328 zasm_debugger = 1;
5329 save_game_configs();
5330 }
5331 }).show();
5332 return D_O_K;
5333 }
5334 else
5335 {
5336 zasm_debugger = 0;
5337 save_game_configs();
5338 FFCore.ZASMPrint(false);
5339 return D_O_K;
5340 }
5341 }
5342
5343
5344 int32_t onConsoleZScript()
5345 {
5346 if ( !zscript_debugger )
5347 {
5348 AlertDialog("ZScript Debugger",
5349 "Enabling this will open the ZScript Debugger Console"
5350 "\nThis will display any messages logged by scripts,"
5351 " including script errors."
5352 "\nAre you sure that you wish to open the ZScript Debugger?",
5353 [&](bool ret,bool)
5354 {
5355 if(ret)
5356 {
5357 FFCore.ZScriptConsole(true);
5358 zscript_debugger = 1;
5359 save_game_configs();
5360 }
5361 }).show();
5362 return D_O_K;
5363 }
5364 else
5365 {
5366 zscript_debugger = 0;
5367 save_game_configs();
5368 FFCore.ZScriptConsole(false);
5369 return D_O_K;
5370 }
5371 }
5372
5373
5374 int32_t onFrameSkip()
5375 {
5376 FrameSkip = !FrameSkip;
5377 return D_O_K;
5378 }
5379
5380 int32_t onSaveDragResize()
5381 {
5382 SaveDragResize = !SaveDragResize;
5383 return D_O_K;
5384 }
5385
5386 int32_t onDragAspect()
5387 {
5388 DragAspect = !DragAspect;
5389 return D_O_K;
5390 }
5391
5392 int32_t onTransLayers()
5393 {
5394 TransLayers = !TransLayers;
5395 save_game_configs();
5396 return D_O_K;
5397 }
5398
5399 int32_t onNESquit()
5400 {
5401 NESquit = !NESquit;
5402 save_game_configs();
5403 return D_O_K;
5404 }
5405
5406 int32_t onVolKeys()
5407 {
5408 volkeys = !volkeys;
5409 save_game_configs();
5410 return D_O_K;
5411 }
5412
5413 int32_t onShowFPS()
5414 {
5415 ShowFPS = !ShowFPS;
5416 save_game_configs();
5417 return D_O_K;
5418 }
5419
5420 83798880 bool is_Fkey(int32_t k)
5421 {
5422
2/2
✓ Branch 0 taken 8521920 times.
✓ Branch 1 taken 75276960 times.
83798880 switch(k)
5423 {
5424 case KEY_F1:
5425 case KEY_F2:
5426 case KEY_F3:
5427 case KEY_F4:
5428 case KEY_F5:
5429 case KEY_F6:
5430 case KEY_F7:
5431 case KEY_F8:
5432 case KEY_F9:
5433 case KEY_F10:
5434 case KEY_F11:
5435 case KEY_F12:
5436 8521920 return true;
5437 }
5438
5439 75276960 return false;
5440 83798880 }
5441
5442 void kb_getkey(DIALOG *d)
5443 {
5444 d->flags|=D_SELECTED;
5445
5446 scare_mouse();
5447 jwin_button_proc(MSG_DRAW,d,0);
5448 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5449 // text_mode(vc(11));
5450 textout_centre_ex(gui_bmp, font, "Press a key", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5451 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5452 unscare_mouse();
5453
5454 update_hw_screen(true);
5455
5456 clear_keybuf();
5457 int32_t k = next_press_key();
5458 clear_keybuf();
5459
5460 //shnarf
5461 //47=f1
5462 //59=esc
5463 if(k>0 && k<123 && !((k>46)&&(k<60)))
5464 *((int32_t*)d->dp3) = k;
5465
5466
5467 d->flags&=~D_SELECTED;
5468 }
5469
5470
5471 //Used by all keyboard key settings dialogues.
5472 void kb_clearjoystick(DIALOG *d)
5473 {
5474 d->flags|=D_SELECTED;
5475
5476 scare_mouse();
5477 jwin_button_proc(MSG_DRAW,d,0);
5478 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5479 // text_mode(vc(11));
5480 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5481 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5482 unscare_mouse();
5483
5484 update_hw_screen(true);
5485
5486 clear_keybuf();
5487 int32_t k = next_press_key();
5488 clear_keybuf();
5489
5490 //shnarf
5491 //47=f1
5492 //59=esc
5493 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5494 // *((int32_t*)d->dp3) = k;
5495 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5496
5497
5498 d->flags&=~D_SELECTED;
5499 }
5500
5501 //Clears key to 0.
5502 //Used by all keyboard key settings dialogues.
5503 void kb_clearkey(DIALOG *d)
5504 {
5505 d->flags|=D_SELECTED;
5506
5507 scare_mouse();
5508 jwin_button_proc(MSG_DRAW,d,0);
5509 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5510 // text_mode(vc(11));
5511 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5512 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5513 unscare_mouse();
5514
5515 update_hw_screen(true);
5516
5517 clear_keybuf();
5518 int32_t k = next_press_key();
5519 clear_keybuf();
5520
5521 //shnarf
5522 //47=f1
5523 //59=esc
5524 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5525 // *((int32_t*)d->dp3) = k;
5526 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5527
5528
5529 d->flags&=~D_SELECTED;
5530 }
5531
5532
5533 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5534 {
5535 switch(msg)
5536 {
5537 case MSG_KEY:
5538 case MSG_CLICK:
5539
5540 kb_clearjoystick(d);
5541
5542 while(gui_mouse_b())
5543 {
5544 clear_keybuf();
5545 rest(1);
5546 }
5547
5548 return D_REDRAW;
5549 }
5550
5551 return jwin_button_proc(msg,d,c);
5552 }
5553
5554 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5555 {
5556 switch(msg)
5557 {
5558 case MSG_KEY:
5559 case MSG_CLICK:
5560
5561 kb_getkey(d);
5562
5563 while(gui_mouse_b()) {
5564 clear_keybuf();
5565 rest(1);
5566 }
5567
5568 return D_REDRAW;
5569 }
5570
5571 return jwin_button_proc(msg,d,c);
5572 }
5573
5574 //Only used in keyboard settings dialogues to clear keys.
5575 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5576 {
5577 switch(msg)
5578 {
5579 case MSG_KEY:
5580 case MSG_CLICK:
5581
5582 kb_clearkey(d);
5583
5584 while(gui_mouse_b()) {
5585 clear_keybuf();
5586 rest(1);
5587 }
5588
5589 return D_REDRAW;
5590 }
5591
5592 return jwin_button_proc(msg,d,c);
5593 }
5594
5595 void j_getbtn(DIALOG *d)
5596 {
5597 d->flags|=D_SELECTED;
5598 scare_mouse();
5599 jwin_button_proc(MSG_DRAW,d,0);
5600 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5601 // text_mode(vc(11));
5602 int32_t y = gui_bmp->h/2 - 12;
5603 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5604 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5605 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5606 unscare_mouse();
5607
5608 update_hw_screen(true);
5609
5610 int32_t b = next_press_btn();
5611
5612 if(b>=0)
5613 *((int32_t*)d->dp3) = b;
5614
5615 d->flags&=~D_SELECTED;
5616
5617 if (player)
5618 player->joy_on = TRUE;
5619 }
5620
5621 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5622 {
5623 switch(msg)
5624 {
5625 case MSG_KEY:
5626 case MSG_CLICK:
5627
5628 j_getbtn(d);
5629
5630 while(gui_mouse_b()) {
5631 rest(1);
5632 clear_keybuf();
5633 }
5634
5635 return D_REDRAW;
5636 }
5637
5638 return jwin_button_proc(msg,d,c);
5639 }
5640
5641 //shnarf
5642 const char *key_str[] =
5643 {
5644 "(none) ", "a ", "b ", "c ",
5645 "d ", "e ", "f ", "g ",
5646 "h ", "i ", "j ", "k ",
5647 "l ", "m ", "n ", "o ",
5648 "p ", "q ", "r ", "s ",
5649 "t ", "u ", "v ", "w ",
5650 "x ", "y ", "z ", "0 ",
5651 "1 ", "2 ", "3 ", "4 ",
5652 "5 ", "6 ", "7 ", "8 ",
5653 "9 ", "num 0 ", "num 1 ", "num 2 ",
5654 "num 3 ", "num 4 ", "num 5 ", "num 6 ",
5655 "num 7 ", "num 8 ", "num 9 ", "f1 ",
5656 "f2 ", "f3 ", "f4 ", "f5 ",
5657 "f6 ", "f7 ", "f8 ", "f9 ",
5658 "f10 ", "f11 ", "f12 ", "esc ",
5659 "~ ", "- ", "= ", "backspace ",
5660 "tab ", "{ ", "} ", "enter ",
5661 ": ", "quote ", "\\ ", "\\ (2) ",
5662 ", ", ". ", "/ ", "space ",
5663 "insert ", "delete ", "home ", "end ",
5664 "page up ", "page down ", "left ", "right ",
5665 "up ", "down ", "num / ", "num * ",
5666 "num - ", "num + ", "num delete ", "num enter ",
5667 "print screen ", "pause ", "abnt c1 ", "yen ",
5668 "kana ", "convert ", "no convert ", "at ",
5669 "circumflex ", ": (2) ", "kanji ", "num = ",
5670 "back quote ", "; ", "command ", "unknown (0) ",
5671 "unknown (1) ", "unknown (2) ", "unknown (3) ", "unknown (4) ",
5672 "unknown (5) ", "unknown (6) ", "unknown (7) ", "left shift ",
5673 "right shift ", "left control ", "right control", "alt ",
5674 "alt gr ", "left win ", "right win ", "menu ",
5675 "scroll lock ", "number lock ", "caps lock ", "MAX"
5676 };
5677
5678
5679 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5680 //extern int32_t zcmusic_bufsz;
5681
5682 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5683 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5684
5685 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5686 {
5687 //these are here to bypass compiler warnings about unused arguments
5688 c=c;
5689
5690 if(msg==MSG_DRAW)
5691 {
5692 switch(d->w)
5693 {
5694 case 0:
5695 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5696 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5697 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5698 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5699 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5700 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5701 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5702 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5703 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5704 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5705 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5706 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5707 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5708 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5709 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5710 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5711 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5712 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5713 break;
5714
5715 case 1:
5716 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5717 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5718 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5719 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5720 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5721 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5722 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5723 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5724 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5725 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5726 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5727 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5728 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5729 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5730 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5731 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5732 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5733 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5734 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5735 break;
5736
5737 case 2:
5738 sprintf(str_a,"%3d",midi_volume);
5739 sprintf(str_b,"%3d",digi_volume);
5740 sprintf(str_l,"%3d",emusic_volume);
5741 sprintf(str_m,"%3dKB",zcmusic_bufsz);
5742 sprintf(str_r,"%3d",sfx_volume);
5743 strcpy(str_s,pan_str[pan_style]);
5744 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5745 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5746 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5747 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5748 break;
5749 }
5750 }
5751
5752 return D_O_K;
5753 }
5754
5755 int32_t set_vol(void *dp3, int32_t d2)
5756 {
5757 switch(((int32_t*)dp3)[0])
5758 {
5759 case 0:
5760 midi_volume = zc_min(d2<<3,255);
5761 break;
5762
5763 case 1:
5764 digi_volume = zc_min(d2<<3,255);
5765 break;
5766
5767 case 2:
5768 emusic_volume = zc_min(d2<<3,255);
5769 break;
5770
5771 case 3:
5772 sfx_volume = zc_min(d2<<3,255);
5773 break;
5774 }
5775
5776 scare_mouse();
5777 // text_mode(vc(11));
5778 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5779 unscare_mouse();
5780 return D_O_K;
5781 }
5782
5783 int32_t set_pan(void *dp3, int32_t d2)
5784 {
5785 pan_style = vbound(d2,0,3);
5786 scare_mouse();
5787 // text_mode(vc(11));
5788 textout_right_ex(screen,is_large ? lfont_l : font, pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5789 unscare_mouse();
5790 return D_O_K;
5791 }
5792
5793 int32_t set_buf(void *dp3, int32_t d2)
5794 {
5795 scare_mouse();
5796 // text_mode(vc(11));
5797 zcmusic_bufsz = d2 + 1;
5798 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5799 unscare_mouse();
5800 return D_O_K;
5801 }
5802
5803 static int32_t gamepad_btn_list[] =
5804 {
5805 6,
5806 7,8,9,10,11,12,13,14,15,16,17,
5807 18,19,20,21,22,23,24,25,26,27,28,
5808 29,30,31,32,33,34,35,36,37,38,39,
5809 -1
5810 };
5811
5812 static int32_t gamepad_dirs_list[] =
5813 {
5814 40,41,42,43,
5815 44,45,46,47,
5816 48,49,50,51,
5817 52,53,54,55,
5818 56,
5819 -1
5820 };
5821
5822 static TABPANEL gamepad_tabs[] =
5823 {
5824 // (text)
5825 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5826 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5827 { NULL, 0, NULL, 0, NULL }
5828 };
5829
5830 static DIALOG gamepad_dlg[] =
5831 {
5832 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5833 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5834 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5835 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5836 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5837 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5838 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5839 // 6
5840 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5841 // 7
5842 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5843 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5844 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5845 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5846 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5847 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5848 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5849 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5850 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5851 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5852 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5853 // 18
5854 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5855 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5856 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5857 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5858 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5859 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5860 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5861 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5862 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5863 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5864 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5865 // 29
5866 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5867 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5868 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5869 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5870 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5871 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5872 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5873 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5874 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5875 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5876 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5877 // 40
5878 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5879 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5880 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5881 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5882 // 44
5883 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5884 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5885 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5886 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5887 // 48
5888 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5889 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5890 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5891 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5892 // 52
5893 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5894 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5895 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5896 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5897 // 56
5898 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5899 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5900 };
5901
5902 static int32_t keyboard_keys_list[] =
5903 {
5904 6,7,8,9,10,
5905 11,12,13,14,15,16,17,18,19,20,
5906 21,22,23,24,25,26,27,28,29,30,
5907 31,32,33,34,35,36,37,38,39,40,
5908 -1
5909 };
5910
5911 static int32_t keyboard_dirs_list[] =
5912 {
5913 41,42,43,44,
5914 45,46,47,48,
5915 49,50,51,52,
5916 53,54,55,56,
5917 -1
5918 };
5919
5920 static int32_t keyboard_mods_list[] =
5921 {
5922 57,58,59,60,
5923 61,62,63,64,
5924 65,66,67,68,
5925 69,70,71,72,
5926 -1
5927 };
5928
5929 static TABPANEL keyboard_control_tabs[] =
5930 {
5931 // (text)
5932 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5933 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5934 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5935 { NULL, 0, NULL, 0, NULL }
5936 };
5937
5938 static DIALOG keyboard_control_dlg[] =
5939 {
5940 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5941 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5942 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5943 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5944 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5945 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5946 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5947 // Keys
5948 // 6
5949 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5950 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5951 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5952 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5953 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5954 // 11
5955 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5956 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5957 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5958 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5959 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5960 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5961 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5962 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5963 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5964 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5965 // 21
5966 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5967 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5968 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5969 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5970 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5971 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5972 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5973 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5974 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5975 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5976 // 31
5977 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5978 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5979 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5980 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5981 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5982 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5983 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5984 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5985 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5986 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5987 // Dirs
5988 // 41
5989 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5990 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5991 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5992 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5993 // 45
5994 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5995 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5996 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5997 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5998 // 49
5999 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
6000 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
6001 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
6002 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
6003 // 53
6004 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
6005 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
6006 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
6007 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
6008 // Mods
6009 // 57
6010 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6011 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6012 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
6013 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
6014 // 61
6015 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
6016 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
6017 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
6018 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
6019 // 65
6020 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
6021 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
6022 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
6023 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
6024 // 69
6025 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
6026 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
6027 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
6028 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
6029 // 73
6030 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6031 };
6032
6033 /*
6034 int32_t midi_dp[3] = {0,147,104};
6035 int32_t digi_dp[3] = {1,147,120};
6036 int32_t pan_dp[3] = {0,147,136};
6037 int32_t buf_dp[3] = {0,147,152};
6038 */
6039 int32_t midi_dp[3] = {0,0,0};
6040 int32_t digi_dp[3] = {1,0,0};
6041 int32_t emus_dp[3] = {2,0,0};
6042 int32_t buf_dp[3] = {0,0,0};
6043 int32_t sfx_dp[3] = {3,0,0};
6044 int32_t pan_dp[3] = {0,0,0};
6045
6046 static DIALOG sound_dlg[] =
6047 {
6048 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
6049 9 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
6050 9 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6051 9 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6052 9 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6053 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6054 9 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6055 9 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
6056 9 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
6057 9 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
6058 9 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
6059 // 10
6060 9 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
6061 9 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
6062 9 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6063 9 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6064 9 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6065 9 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
6066 9 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
6067 9 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
6068 9 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
6069 9 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
6070 //20
6071 9 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
6072 9 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6073 9 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6074 9 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6075 9 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
6076 9 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
6077 9 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
6078 9 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
6079 9 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
6080 9 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
6081 //30
6082 9 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6083 9 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6084 9 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6085 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6086 };
6087
6088 char zc_builddate[80];
6089 char zc_aboutstr[80];
6090
6091 static DIALOG about_dlg[] =
6092 {
6093 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6094 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
6095 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6096 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
6097 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6098 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
6099 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
6100 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
6101 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
6102 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
6103 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6104 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6105 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6106 };
6107
6108
6109 static DIALOG quest_dlg[] =
6110 {
6111 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6112 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
6113 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
6114 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
6115 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
6116 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
6117 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, QHeader.version, NULL, NULL },
6118 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
6119 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6120 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
6121 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
6122 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
6123 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
6124 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6125 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6126 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6127 };
6128
6129 static DIALOG triforce_dlg[] =
6130 {
6131 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
6132 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
6133 // 1
6134 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
6135 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
6136 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
6137 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
6138 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
6139 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
6140 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
6141 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
6142 // 9
6143 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6144 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6145 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6146 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6147 };
6148
6149 /*static DIALOG equip_dlg[] =
6150 {
6151 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6152 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Equipment", NULL, NULL },
6153 // 1
6154 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6155 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6156 // 3
6157 { jwin_frame_proc, 25, 45, 77, 50, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6158 { jwin_text_proc, 29, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Sword", NULL, NULL },
6159 { jwin_check_proc, 33, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6160 { jwin_check_proc, 33, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "White", NULL, NULL },
6161 { jwin_check_proc, 33, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6162 { jwin_check_proc, 33, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Master", NULL, NULL },
6163 // 9
6164 { jwin_frame_proc, 25, 99, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6165 { jwin_text_proc, 29, 96, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Shield", NULL, NULL },
6166 { jwin_check_proc, 33, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6167 { jwin_check_proc, 33, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6168 { jwin_check_proc, 33, 126, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Mirror", NULL, NULL },
6169 // 14
6170 { jwin_frame_proc, 25, 143, 61, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6171 { jwin_text_proc, 29, 140, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Ring", NULL, NULL },
6172 { jwin_check_proc, 33, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6173 { jwin_check_proc, 33, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6174 { jwin_check_proc, 33, 170, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Gold", NULL, NULL },
6175 // 19
6176 { jwin_frame_proc, 110, 45, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6177 { jwin_text_proc, 114, 42, 64, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bracelet", NULL, NULL },
6178 { jwin_check_proc, 118, 52, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6179 { jwin_check_proc, 118, 62, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6180 // 23
6181 { jwin_frame_proc, 110, 79, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6182 { jwin_text_proc, 114, 76, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Amulet", NULL, NULL },
6183 { jwin_check_proc, 118, 86, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6184 { jwin_check_proc, 118, 96, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6185 // 27
6186 { jwin_frame_proc, 110, 113, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6187 { jwin_text_proc, 114, 110, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Wallet", NULL, NULL },
6188 { jwin_check_proc, 118, 120, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6189 { jwin_check_proc, 118, 130, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6190 // 31
6191 { jwin_frame_proc, 110, 147, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6192 { jwin_text_proc, 114, 144, 24, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bow", NULL, NULL },
6193 { jwin_check_proc, 118, 154, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6194 { jwin_check_proc, 118, 164, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6195 // 35
6196 { jwin_frame_proc, 203, 45, 93, 70, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6197 { jwin_text_proc, 207, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6198 { jwin_check_proc, 211, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Raft", NULL, NULL },
6199 { jwin_check_proc, 211, 62, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Ladder", NULL, NULL },
6200 { jwin_check_proc, 211, 72, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Book", NULL, NULL },
6201 { jwin_check_proc, 211, 82, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic Key", NULL, NULL },
6202 { jwin_check_proc, 211, 92, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Flippers", NULL, NULL },
6203 { jwin_check_proc, 211, 102, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Boots", NULL, NULL },
6204 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6205 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6206 };
6207
6208 static DIALOG items_dlg[] =
6209 {
6210 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6211 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Items", NULL, NULL },
6212 //1
6213 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6214 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6215 // 3
6216 { jwin_frame_proc, 27, 45, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6217 { jwin_text_proc, 31, 42, 64, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Boomerang", NULL, NULL },
6218 { jwin_check_proc, 35, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6219 { jwin_check_proc, 35, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6220 { jwin_check_proc, 35, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Fire", NULL, NULL },
6221 // 8
6222 { jwin_frame_proc, 27, 89, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6223 { jwin_text_proc, 31, 86, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Arrow", NULL, NULL },
6224 { jwin_check_proc, 35, 96, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6225 { jwin_check_proc, 35, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Silver", NULL, NULL },
6226 { jwin_check_proc, 35, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Golden", NULL, NULL },
6227 // 13
6228 { jwin_frame_proc, 27, 133, 63, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6229 { jwin_text_proc, 31, 130, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Potion", NULL, NULL },
6230 { jwin_radio_proc, 35, 140, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "None", NULL, NULL },
6231 { jwin_radio_proc, 35, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6232 { jwin_radio_proc, 35, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6233 // 18
6234 { jwin_frame_proc, 114, 45, 93, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6235 { jwin_text_proc, 118, 42, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Whistle", NULL, NULL },
6236 { jwin_check_proc, 122, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Recorder", NULL, NULL },
6237 // 21
6238 { jwin_frame_proc, 114, 69, 86, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6239 { jwin_text_proc, 118, 66, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hammer", NULL, NULL },
6240 { jwin_check_proc, 122, 76, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6241 // 24
6242 { jwin_frame_proc, 114, 93, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6243 { jwin_text_proc, 118, 90, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hookshot", NULL, NULL },
6244 { jwin_check_proc, 122, 100, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Short", NULL, NULL },
6245 { jwin_check_proc, 122, 110, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Long", NULL, NULL },
6246 // 28
6247 { jwin_frame_proc, 114, 127, 60, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6248 { jwin_text_proc, 118, 124, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Candle", NULL, NULL },
6249 { jwin_check_proc, 122, 134, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6250 { jwin_check_proc, 122, 144, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6251 // 32
6252 { jwin_frame_proc, 217, 45, 77, 138, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6253 { jwin_text_proc, 221, 42, 80, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6254 { jwin_check_proc, 225, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Bait", NULL, NULL },
6255 { jwin_check_proc, 225, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Letter", NULL, NULL },
6256 { jwin_check_proc, 225, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wand", NULL, NULL },
6257 { jwin_check_proc, 225, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Lens", NULL, NULL },
6258 { jwin_check_proc, 225, 92, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Din's Fire", NULL, NULL },
6259 { jwin_check_proc, 225, 102, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Farore's Wind", NULL, NULL },
6260 { jwin_check_proc, 225, 112, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Nayru's Love", NULL, NULL },
6261 { jwin_text_proc, 225, 132, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bombs:", NULL, NULL },
6262 { jwin_edit_proc, 229, 142, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6263 { jwin_text_proc, 225, 162, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "S-Bombs:", NULL, NULL },
6264 { jwin_edit_proc, 229, 162, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6265 { jwin_check_proc, 225, 122, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Cane of Byrna", NULL, NULL },
6266 //45
6267 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6268 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6269 };*/
6270
6271
6272
6273 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6274 {
6275 go();
6276 int32_t ret=0;
6277 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6278 comeback();
6279 return ret != 0;
6280 }
6281
6282
6283 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6284 {
6285 if(def!=modulepath)
6286 strcpy(modulepath,def);
6287
6288 if(!usefilename)
6289 {
6290 int32_t i=(int32_t)strlen(modulepath);
6291
6292 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6293 modulepath[i--]=0;
6294 }
6295
6296 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6297 int32_t ret=0;
6298 int32_t sel=0;
6299
6300 if(list==NULL)
6301 {
6302 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,lfont);
6303 }
6304 else
6305 {
6306 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, lfont);
6307 }
6308
6309 return ret!=0;
6310 }
6311
6312 //The Dialogue that loads a ZMOD Module File
6313 int32_t zc_load_zmod_module_file()
6314 {
6315 if ( Playing )
6316 {
6317 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6318 return -1;
6319 }
6320 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
6321 return D_CLOSE;
6322
6323 FILE *tempmodule = fopen(modulepath,"r");
6324
6325 if(tempmodule == NULL)
6326 {
6327 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6328 return -1;
6329 }
6330
6331
6332 //Set the module path:
6333 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6334 strcpy(moduledata.module_name, modulepath);
6335 al_trace("New Module Path is: %s \n", moduledata.module_name);
6336 set_config_string("ZCMODULE","current_module",moduledata.module_name);
6337 //save_game_configs();
6338 zcm.init(true); //Load the module values.
6339 moduledata.refresh_title_screen = 1;
6340 // refresh_select_screen = 1;
6341 build_biic_list();
6342 return D_O_K;
6343 }
6344
6345 static DIALOG module_info_dlg[] =
6346 {
6347 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6348
6349
6350 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6351 //1
6352 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6353 //2
6354 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6355 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6356 //4
6357 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6358 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6359 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6360 //7
6361
6362 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6363 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6364 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6365 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6366 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6367 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6368 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6369 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6370 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6371
6372 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6373 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6374 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6375 };
6376
6377 void about_zcplayer_module(const char *prompt,int32_t initialval)
6378 {
6379
6380 module_info_dlg[0].dp2 = lfont;
6381 if ( moduledata.moduletitle[0] != 0 )
6382 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6383
6384 if ( moduledata.moduleauthor[0] != 0 )
6385 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6386
6387 if ( moduledata.moduleinfo0[0] != 0 )
6388 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6389 if ( moduledata.moduleinfo1[0] != 0 )
6390 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6391 if ( moduledata.moduleinfo2[0] != 0 )
6392 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6393 if ( moduledata.moduleinfo3[0] != 0 )
6394 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6395 if ( moduledata.moduleinfo4[0] != 0 )
6396 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6397
6398 char module_date[255];
6399 memset(module_date, 0, sizeof(module_date));
6400 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6401 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6402
6403
6404
6405 char module_vers[255];
6406 memset(module_vers, 0, sizeof(module_vers));
6407 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6408
6409
6410 //sprintf(tilecount,"%d",1);
6411
6412 char module_build[255];
6413 memset(module_build, 0, sizeof(module_build));
6414 if ( moduledata.modbeta )
6415 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6416 else
6417 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6418
6419 module_info_dlg[12].dp = (char*)module_date;
6420 module_info_dlg[13].dp = (char*)module_vers;
6421 module_info_dlg[14].dp = (char*)module_build;
6422
6423 if(is_large)
6424 large_dialog(module_info_dlg);
6425
6426 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6427 jwin_center_dialog(module_info_dlg);
6428
6429
6430 }
6431
6432 int32_t onAbout_ZCP_Module()
6433 {
6434 about_zcplayer_module("About Module (.zmod)", 0);
6435 return D_O_K;
6436 }
6437
6438 //New Modules Menu for 2.55+
6439 static MENU zcmodule_menu[] =
6440 {
6441 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6442 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6443
6444 { NULL, NULL, NULL, 0, NULL }
6445 };
6446
6447 int32_t onToggleRecordingNewSaves()
6448 {
6449 if (zc_get_config("zeldadx", "replay_new_saves", false))
6450 {
6451 zc_set_config("zeldadx", "replay_new_saves", false);
6452 }
6453 else
6454 {
6455 zc_set_config("zeldadx", "replay_new_saves", true);
6456 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6457 NULL,NULL,"OK",NULL,13,27,lfont);
6458 }
6459 return D_O_K;
6460 }
6461
6462 int32_t onStopReplayOrRecord()
6463 {
6464 if (replay_is_replaying())
6465 {
6466 replay_quit();
6467 }
6468 else if (replay_get_mode() == ReplayMode::Record)
6469 {
6470 if (!replay_get_meta_bool("test_mode"))
6471 {
6472 jwin_alert("Recording", "You cannot stop recording a save file.",
6473 NULL,NULL,"OK",NULL,13,27,lfont);
6474 return D_CLOSE;
6475 }
6476
6477 if (jwin_alert("Stop Recording",
6478 "Save replay to disk and stop recording?",
6479 "This will stop the recording.",
6480 NULL,
6481 "Yes","No",13,27,lfont) != 1)
6482 return D_CLOSE;
6483
6484 replay_save();
6485 replay_stop();
6486 }
6487 return D_O_K;
6488 }
6489
6490 static int32_t handle_on_load_replay(ReplayMode mode)
6491 {
6492 if (Playing)
6493 {
6494 if (jwin_alert("Replay - Warning!",
6495 "Loading a replay will exit the current game.",
6496 "All unsaved progress will be lost.",
6497 "Do you wish to continue?",
6498 "Yes","No",13,27,lfont) != 1)
6499 return D_CLOSE;
6500 }
6501
6502 std::string mode_string = replay_mode_to_string(mode);
6503 mode_string[0] = std::toupper(mode_string[0]);
6504
6505 std::string line_1 = "Select a replay file to play back.";
6506 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6507 std::string line_3 = "You can stop the replay and take over manually any time.";
6508 if (mode == ReplayMode::Update)
6509 {
6510 line_1 = "Select a replay file to update.";
6511 line_2 = "WARNING: be sure to back up the zplay file";
6512 line_3 = "and verify that the updated replay works as expected!";
6513 }
6514
6515 if (jwin_alert(mode_string.c_str(),
6516 line_1.c_str(),
6517 line_2.c_str(),
6518 line_3.c_str(),
6519 "OK","Nevermind",13,27,lfont) == 1)
6520 {
6521 char replay_path[2048];
6522 strcpy(replay_path, "replays/");
6523 if (jwin_file_select_ex(
6524 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6525 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6526 return D_CLOSE;
6527
6528 replay_quit();
6529 load_replay_file_deferred(mode, replay_path);
6530 Quit = qRESET;
6531 return D_CLOSE;
6532 }
6533 return D_O_K;
6534 }
6535
6536 int32_t onLoadReplay()
6537 {
6538 return handle_on_load_replay(ReplayMode::Replay);
6539 }
6540
6541 int32_t onLoadReplayAssert()
6542 {
6543 return handle_on_load_replay(ReplayMode::Assert);
6544 }
6545
6546 int32_t onLoadReplayUpdate()
6547 {
6548 return handle_on_load_replay(ReplayMode::Update);
6549 }
6550
6551 int32_t onSaveReplay()
6552 {
6553 if (replay_get_mode() == ReplayMode::Record)
6554 {
6555 if (!replay_get_meta_bool("test_mode"))
6556 {
6557 if (jwin_alert("Save Replay",
6558 "This will save a copy of the replay up to this point.",
6559 "The official replay file will be untouched.",
6560 "Do you wish to continue?",
6561 "Yes","No",13,27,lfont) != 1)
6562 return D_CLOSE;
6563
6564 char replay_path[2048];
6565 strcpy(replay_path, replay_get_filename().c_str());
6566 if (jwin_file_select_ex(
6567 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6568 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6569 return D_CLOSE;
6570
6571 if (fileexists(replay_path))
6572 {
6573 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6574 NULL,NULL,"OK",NULL,13,27,lfont);
6575 return D_CLOSE;
6576 }
6577
6578 replay_save(replay_path);
6579 }
6580 else
6581 {
6582 replay_save();
6583 }
6584 }
6585 return D_O_K;
6586 }
6587
6588 static MENU replay_menu[] =
6589 {
6590 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6591 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6592 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6593 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6594 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6595 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6596
6597 { NULL, NULL, NULL, 0, NULL }
6598 };
6599
6600 static DIALOG credits_dlg[] =
6601 {
6602 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6603 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6604 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6605 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6606 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6607 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6608 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6609 };
6610
6611 9 static ListData dmap_list(dmaplist, &font);
6612
6613 static DIALOG goto_dlg[] =
6614 {
6615 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6616 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6617 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6618 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6619 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6620 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6621 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6622 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6623 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6624 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6625 };
6626
6627 int32_t onGoTo()
6628 {
6629 bool music = false;
6630 music = music;
6631 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6632
6633 goto_dlg[0].dp2=lfont;
6634 goto_dlg[4].d2=cheat_goto_dmap;
6635 goto_dlg[6].dp=cheat_goto_screen_str;
6636
6637 clear_keybuf();
6638
6639 if(is_large)
6640 large_dialog(goto_dlg);
6641
6642 if(zc_popup_dialog(goto_dlg,4)==1)
6643 {
6644 // dmap, screen
6645 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6646 };
6647
6648 return D_O_K;
6649 }
6650
6651 int32_t onGoToComplete()
6652 {
6653 if(!Playing)
6654 {
6655 return D_O_K;
6656 }
6657
6658 system_pal();
6659 music_pause();
6660 pause_all_sfx();
6661 show_mouse(screen);
6662 onGoTo();
6663 eat_buttons();
6664
6665 zc_readrawkey(KEY_ESC);
6666
6667 show_mouse(NULL);
6668 game_pal();
6669 music_resume();
6670 resume_all_sfx();
6671 return D_O_K;
6672 }
6673
6674 int32_t onCredits()
6675 {
6676 go();
6677
6678 BITMAP *win = create_bitmap_ex(8,222,110);
6679
6680 if(!win)
6681 return D_O_K;
6682
6683 int32_t c=0;
6684 int32_t l=0;
6685 int32_t ol=-1;
6686 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6687 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6688 PALETTE tmppal;
6689
6690 rti_gui.transparency_index = 1;
6691
6692 clear_to_color(win, rti_gui.transparency_index);
6693 draw_rle_sprite(win,rle,0,0);
6694 credits_dlg[0].dp2=lfont;
6695 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6696 credits_dlg[2].dp = win;
6697
6698 set_palette_range(black_palette,0,127,false);
6699
6700 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6701
6702 BITMAP* old_screen = screen;
6703 BITMAP* gui_bmp = zc_get_gui_bmp();
6704 ASSERT(gui_bmp);
6705 clear_to_color(gui_bmp, rti_gui.transparency_index);
6706 screen = gui_bmp;
6707
6708 while(update_dialog(p))
6709 {
6710 throttleFPS();
6711 ++c;
6712 l = zc_max((c>>1)-30,0);
6713
6714 if(l > rle->h)
6715 l = c = 0;
6716
6717 if(l > rle->h - 112)
6718 l = rle->h - 112;
6719
6720 clear_bitmap(win);
6721 draw_rle_sprite(win,rle,0,0-l);
6722
6723 if(c<=64)
6724 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6725
6726 set_palette_range(tmppal,0,127,false);
6727
6728 if(l!=ol)
6729 {
6730 scare_mouse();
6731 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6732 unscare_mouse();
6733 SCRFIX();
6734 ol=l;
6735 }
6736
6737 update_hw_screen();
6738 }
6739
6740 screen = old_screen;
6741 system_pal();
6742
6743 shutdown_dialog(p);
6744 destroy_bitmap(win);
6745 //comeback();
6746
6747 rti_gui.transparency_index = 0;
6748
6749 return D_O_K;
6750 }
6751
6752 const char *midilist(int32_t index, int32_t *list_size)
6753 {
6754 if(index<0)
6755 {
6756 *list_size=0;
6757
6758 for(int32_t i=0; i<MAXMIDIS; i++)
6759 if(tunes[i].data)
6760 ++(*list_size);
6761
6762 return NULL;
6763 }
6764
6765 int32_t i=0,m=0;
6766
6767 while(m<=index && i<=MAXMIDIS)
6768 {
6769 if(tunes[i].data)
6770 ++m;
6771
6772 ++i;
6773 }
6774
6775 --i;
6776
6777 if(i==MAXMIDIS && m<index)
6778 return "(null)";
6779
6780 return tunes[i].title;
6781 }
6782
6783 /* ------- MIDI info stuff -------- */
6784
6785 char *text;
6786 midi_info *zmi;
6787 bool dialog_running;
6788 bool listening;
6789
6790 void get_info(int32_t index);
6791
6792 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6793 {
6794 int32_t d2 = d->d2;
6795 int32_t ret = jwin_droplist_proc(msg,d,c);
6796
6797 if(d2!=d->d2)
6798 {
6799 get_info(d->d2);
6800 }
6801
6802 return ret;
6803 }
6804
6805 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6806 {
6807 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6808
6809 int32_t ret = jwin_button_proc(msg,d,c);
6810
6811 if(ret == D_CLOSE)
6812 {
6813 // get current midi index
6814 int32_t index = (d+(d->d1))->d2;
6815 int32_t i=0, m=0;
6816
6817 while(m<=index && i<=MAXMIDIS)
6818 {
6819 if(tunes[i].data)
6820 ++m;
6821
6822 ++i;
6823 }
6824
6825 --i;
6826 jukebox(i);
6827 listening = true;
6828 ret = D_O_K;
6829 }
6830
6831 return ret;
6832 }
6833
6834 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6835 {
6836 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6837
6838 int32_t ret = jwin_button_proc(msg,d,c);
6839
6840 if(ret == D_CLOSE)
6841 {
6842 // get current midi index
6843 int32_t index = (d+(d->d1))->d2;
6844 int32_t i=0, m=0;
6845
6846 while(m<=index && i<=MAXMIDIS)
6847 {
6848 if(tunes[i].data)
6849 ++m;
6850
6851 ++i;
6852 }
6853
6854 --i;
6855
6856 // get file name
6857
6858 int32_t sel=0;
6859 //struct ffblk f;
6860 char title[40] = "Save MIDI: ";
6861 char fname[2048];
6862 memset(fname,0,2048);
6863 static EXT_LIST list[] =
6864 {
6865 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6866 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6867 { NULL, NULL }
6868 };
6869
6870 strcpy(title+11, tunes[i].title);
6871 title[39] = '\0';
6872
6873 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, lfont)==0)
6874 goto done;
6875
6876 if(exists(fname))
6877 {
6878 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',lfont)==2)
6879 goto done;
6880 }
6881
6882 // save midi i
6883
6884 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6885 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,lfont);
6886
6887 done:
6888 chop_path(fname);
6889 ret = D_REDRAW;
6890 }
6891
6892 return ret;
6893 }
6894
6895 9 static ListData midi_list(midilist, &font);
6896
6897 static DIALOG midi_dlg[] =
6898 {
6899 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6900 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6901 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6902 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6903 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6904 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6905 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6906 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6907 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6908 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6909 };
6910
6911 void get_info(int32_t index)
6912 {
6913 int32_t i=0, m=0;
6914
6915 while(m<=index && i<=MAXMIDIS)
6916 {
6917 if(tunes[i].data)
6918 ++m;
6919
6920 ++i;
6921 }
6922
6923 --i;
6924
6925 if(i==MAXMIDIS && m<index)
6926 strcpy(text,"(null)");
6927 else
6928 {
6929 get_midi_info((MIDI*)tunes[i].data,zmi);
6930 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6931 }
6932
6933 midi_dlg[0].dp2=lfont;
6934 midi_dlg[3].dp = text;
6935 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6936 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6937
6938 if(dialog_running)
6939 {
6940 scare_mouse();
6941 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6942 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6943 unscare_mouse();
6944 }
6945 }
6946
6947 int32_t onMIDICredits()
6948 {
6949 text = (char*)malloc(4096);
6950 zmi = (midi_info*)malloc(sizeof(midi_info));
6951
6952 if(!text || !zmi)
6953 {
6954 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,lfont);
6955 return D_O_K;
6956 }
6957
6958 bool do_pause_midi = midi_pos >= 0 && currmidi;
6959 auto restore_midi = currmidi;
6960 if(do_pause_midi)
6961 {
6962 paused_midi_pos = midi_pos;
6963 stop_midi();
6964 midi_paused=true;
6965 midi_suspended = midissuspHALTED;
6966 }
6967
6968 midi_dlg[0].dp2=lfont;
6969 midi_dlg[2].d1 = 0;
6970 midi_dlg[2].d2 = 0;
6971 midi_dlg[4].flags = D_EXIT;
6972 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6973
6974 listening = false;
6975 dialog_running=false;
6976 get_info(0);
6977
6978 dialog_running=true;
6979
6980 if(is_large)
6981 large_dialog(midi_dlg);
6982
6983 zc_popup_dialog(midi_dlg,0);
6984 dialog_running=false;
6985
6986 if(listening)
6987 music_stop();
6988
6989 if(do_pause_midi)
6990 {
6991 midi_suspended = midissuspRESUME;
6992 currmidi = restore_midi;
6993 midi_pos = paused_midi_pos;
6994 }
6995
6996 if(text) free(text);
6997 if(zmi) free(zmi);
6998 return D_O_K;
6999 }
7000
7001 int32_t onAbout()
7002 {
7003 char buf1[80]={0};
7004 std::ostringstream oss;
7005 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
7006 oss << buf1 << '\n';
7007 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
7008 oss << buf1 << '\n';
7009 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
7010 oss << buf1 << '\n';
7011 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
7012 oss << buf1 << '\n';
7013
7014 InfoDialog("About ZC", oss.str()).show();
7015 return D_O_K;
7016 }
7017
7018 int32_t onQuest()
7019 {
7020 char fname[100];
7021 strcpy(fname, get_filename(qstpath));
7022 quest_dlg[0].dp2=lfont;
7023 quest_dlg[1].dp = fname;
7024
7025 if(QHeader.quest_number==0)
7026 sprintf(str_a,"Custom");
7027 else
7028 sprintf(str_a,"%d",QHeader.quest_number);
7029
7030 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
7031
7032 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
7033 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
7034
7035 if(is_large)
7036 large_dialog(quest_dlg);
7037
7038 zc_popup_dialog(quest_dlg, 0);
7039 return D_O_K;
7040 }
7041
7042 void call_vidmode_dlg();
7043 int32_t onVidMode()
7044 {
7045 call_vidmode_dlg();
7046 return D_O_K;
7047 }
7048
7049 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
7050 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
7051 //Added an extra statement, so that if the key is cleared to 0, the cleared
7052 //keybinding status need not be unique. -Z ( 1st April, 2019 )
7053
7054 void load_ukeys(int32_t* arr)
7055 {
7056 arr[ukey_a] = Akey;
7057 arr[ukey_b] = Bkey;
7058 arr[ukey_s] = Skey;
7059 arr[ukey_l] = Lkey;
7060 arr[ukey_r] = Rkey;
7061 arr[ukey_p] = Pkey;
7062 arr[ukey_ex1] = Exkey1;
7063 arr[ukey_ex2] = Exkey2;
7064 arr[ukey_ex3] = Exkey3;
7065 arr[ukey_ex4] = Exkey4;
7066 arr[ukey_du] = DUkey;
7067 arr[ukey_dd] = DDkey;
7068 arr[ukey_dl] = DLkey;
7069 arr[ukey_dr] = DRkey;
7070 arr[ukey_mod1a] = cheat_modifier_keys[0];
7071 arr[ukey_mod1b] = cheat_modifier_keys[1];
7072 arr[ukey_mod2a] = cheat_modifier_keys[2];
7073 arr[ukey_mod2b] = cheat_modifier_keys[3];
7074 };
7075
7076 static const char* ukey_names[] = {
7077 "A", "B", "Start", "L", "R", "Map",
7078 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
7079 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
7080 "Cheat Mod R1", "Cheat Mod R2",
7081 };
7082 std::string get_ukey_name(int32_t k)
7083 {
7084 if (k < num_ukey) return ukey_names[k];
7085 return "";
7086 }
7087
7088 int32_t onKeyboard()
7089 {
7090 int32_t a = Akey;
7091 int32_t b = Bkey;
7092 int32_t s = Skey;
7093 int32_t l = Lkey;
7094 int32_t r = Rkey;
7095 int32_t p = Pkey;
7096 int32_t ex1 = Exkey1;
7097 int32_t ex2 = Exkey2;
7098 int32_t ex3 = Exkey3;
7099 int32_t ex4 = Exkey4;
7100 int32_t du = DUkey;
7101 int32_t dd = DDkey;
7102 int32_t dl = DLkey;
7103 int32_t dr = DRkey;
7104 int32_t mod1a = cheat_modifier_keys[0];
7105 int32_t mod1b = cheat_modifier_keys[1];
7106 int32_t mod2a = cheat_modifier_keys[2];
7107 int32_t mod2b = cheat_modifier_keys[3];
7108 bool done=false;
7109 int32_t ret;
7110
7111 keyboard_control_dlg[0].dp2=lfont;
7112
7113 if(is_large)
7114 large_dialog(keyboard_control_dlg);
7115
7116 while(!done)
7117 {
7118 ret = zc_popup_dialog(keyboard_control_dlg,3);
7119
7120 if(ret==3) // OK
7121 {
7122 int32_t ukeys[num_ukey];
7123 load_ukeys(ukeys);
7124 std::vector<std::string> uniqueError;
7125 for(int32_t q = 0; q < num_ukey; ++q)
7126 {
7127 for(int32_t p = q+1; p < num_ukey; ++p)
7128 {
7129 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
7130 {
7131 char buf[64];
7132 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
7133 std::string str(buf);
7134 uniqueError.push_back(str);
7135 }
7136 }
7137 }
7138 if(uniqueError.size() == 0)
7139 done = true;
7140 else
7141 {
7142 box_start(1, "Duplicate Keys", lfont, sfont, false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
7143 box_out("Cannot have duplicate keybinds!"); box_eol();
7144 for(std::vector<std::string>::iterator it = uniqueError.begin();
7145 it != uniqueError.end(); ++it)
7146 {
7147 box_out((*it).c_str()); box_eol();
7148 }
7149 box_end(true);
7150 }
7151 /* Old uniqueness check
7152 std::map<int32_t,bool> *keyhash = new std::map<int32_t,bool>();
7153 bool unique = true;
7154 addToHash(A,unique,keyhash);
7155 addToHash(B,unique,keyhash);
7156 addToHash(S,unique,keyhash);
7157 addToHash(L,unique,keyhash);
7158 addToHash(R,unique,keyhash);
7159 addToHash(P,unique,keyhash);
7160 addToHash(DU,unique,keyhash);
7161 addToHash(DD,unique,keyhash);
7162 addToHash(DL,unique,keyhash);
7163 addToHash(DR,unique,keyhash);
7164
7165 if(keyhash->find(Exkey1) == keyhash->end())
7166 {
7167 (*keyhash)[Exkey1]=true;
7168 }
7169 else
7170 {
7171 if ( Exkey1 != 0 ) unique = false;
7172 }
7173
7174 if(keyhash->find(Exkey2) == keyhash->end())
7175 {
7176 (*keyhash)[Exkey2]=true;
7177 }
7178 else
7179 {
7180 if ( Exkey2 != 0 ) unique = false;
7181 }
7182
7183 if(keyhash->find(Exkey3) == keyhash->end())
7184 {
7185 (*keyhash)[Exkey3]=true;
7186 }
7187 else
7188 {
7189 if ( Exkey3 != 0 ) unique = false;
7190 }
7191
7192 if(keyhash->find(Exkey4) == keyhash->end())
7193 {
7194 (*keyhash)[Exkey4]=true;
7195 }
7196 else
7197 {
7198 if ( Exkey4 != 0 )unique = false;
7199 }
7200 //modifier keys
7201 if(keyhash->find(cheat_modifier_keys[0]) == keyhash->end())
7202 {
7203 (*keyhash)[cheat_modifier_keys[0]]=true;
7204 }
7205 else
7206 {
7207 if ( cheat_modifier_keys[0] != 0 ) unique = false;
7208 }
7209 if(keyhash->find(cheat_modifier_keys[1]) == keyhash->end())
7210 {
7211 (*keyhash)[cheat_modifier_keys[1]]=true;
7212 }
7213 else
7214 {
7215 if ( cheat_modifier_keys[1] != 0 ) unique = false;
7216 }
7217 if(keyhash->find(cheat_modifier_keys[2]) == keyhash->end())
7218 {
7219 (*keyhash)[cheat_modifier_keys[2]]=true;
7220 }
7221 else
7222 {
7223 if ( cheat_modifier_keys[2] != 0 ) unique = false;
7224 }
7225 if(keyhash->find(cheat_modifier_keys[3]) == keyhash->end())
7226 {
7227 (*keyhash)[cheat_modifier_keys[3]]=true;
7228 }
7229 else
7230 {
7231 if ( cheat_modifier_keys[3] != 0 ) unique = false;
7232 }
7233
7234 delete keyhash;
7235
7236 if(unique)
7237 done=true;
7238 else
7239 jwin_alert("Error", "Key bindings must be unique!", "", "", "OK",NULL,'o',0,lfont);
7240 */
7241 }
7242 else // Cancel
7243 {
7244 Akey = a;
7245 Bkey = b;
7246 Skey = s;
7247 Lkey = l;
7248 Rkey = r;
7249 Pkey = p;
7250 Exkey1 = ex1;
7251 Exkey2 = ex2;
7252 Exkey3 = ex3;
7253 Exkey4 = ex4;
7254 DUkey = du;
7255 DDkey = dd;
7256 DLkey = dl;
7257 DRkey = dr;
7258 cheat_modifier_keys[0] = mod1a;
7259 cheat_modifier_keys[1] = mod1b;
7260 cheat_modifier_keys[2] = mod2a;
7261 cheat_modifier_keys[3] = mod2b;
7262
7263 done=true;
7264 }
7265
7266 rest(1);
7267 }
7268
7269 save_game_configs();
7270 return D_O_K;
7271 }
7272
7273 int32_t onGamepad()
7274 {
7275 int32_t a = Abtn;
7276 int32_t b = Bbtn;
7277 int32_t s = Sbtn;
7278 int32_t l = Lbtn;
7279 int32_t r = Rbtn;
7280 int32_t m = Mbtn;
7281 int32_t p = Pbtn;
7282 int32_t ex1 = Exbtn1;
7283 int32_t ex2 = Exbtn2;
7284 int32_t ex3 = Exbtn3;
7285 int32_t ex4 = Exbtn4;
7286 int32_t up = DUbtn;
7287 int32_t down = DDbtn;
7288 int32_t left = DLbtn;
7289 int32_t right = DRbtn;
7290
7291 gamepad_dlg[0].dp2=lfont;
7292 if(analog_movement)
7293 gamepad_dlg[56].flags|=D_SELECTED;
7294 else
7295 gamepad_dlg[56].flags&=~D_SELECTED;
7296
7297 if(is_large)
7298 large_dialog(gamepad_dlg);
7299
7300 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
7301
7302 if(ret == 4) //OK
7303 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
7304 else //Cancel
7305 {
7306 Abtn = a;
7307 Bbtn = b;
7308 Sbtn = s;
7309 Lbtn = l;
7310 Rbtn = r;
7311 Mbtn = m;
7312 Pbtn = p;
7313 Exbtn1 = ex1;
7314 Exbtn2 = ex2;
7315 Exbtn3 = ex3;
7316 Exbtn4 = ex4;
7317 DUbtn = up;
7318 DDbtn = down;
7319 DLbtn = left;
7320 DRbtn = right;
7321 }
7322
7323 save_game_configs();
7324 return D_O_K;
7325 }
7326
7327 int32_t onSound()
7328 {
7329 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
7330 {
7331 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
7332 }
7333 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
7334 {
7335 master_volume((int32_t)(FFCore.usr_digi_volume),1);
7336 }
7337 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
7338 {
7339 emusic_volume = (int32_t)FFCore.usr_music_volume;
7340 }
7341 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7342 {
7343 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7344 }
7345 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7346 {
7347 pan_style = (int32_t)FFCore.usr_panstyle;
7348 }
7349
7350 int32_t m = midi_volume;
7351 int32_t d = digi_volume;
7352 int32_t e = emusic_volume;
7353 int32_t b = zcmusic_bufsz;
7354 int32_t s = sfx_volume;
7355 int32_t p = pan_style;
7356 pan_style = vbound(pan_style,0,3);
7357
7358 sound_dlg[0].dp2=lfont;
7359
7360 if(is_large)
7361 large_dialog(sound_dlg);
7362
7363 midi_dp[1] = sound_dlg[6].x;
7364 midi_dp[2] = sound_dlg[6].y;
7365 digi_dp[1] = sound_dlg[7].x;
7366 digi_dp[2] = sound_dlg[7].y;
7367 emus_dp[1] = sound_dlg[8].x;
7368 emus_dp[2] = sound_dlg[8].y;
7369 buf_dp[1] = sound_dlg[9].x;
7370 buf_dp[2] = sound_dlg[9].y;
7371 sfx_dp[1] = sound_dlg[10].x;
7372 sfx_dp[2] = sound_dlg[10].y;
7373 pan_dp[1] = sound_dlg[11].x;
7374 pan_dp[2] = sound_dlg[11].y;
7375 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7376 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7377 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7378 sound_dlg[18].d2 = zcmusic_bufsz;
7379 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7380 sound_dlg[20].d2 = pan_style;
7381
7382 int32_t ret = zc_popup_dialog(sound_dlg,1);
7383
7384 if(ret==2)
7385 {
7386 master_volume(digi_volume,midi_volume);
7387
7388 for(int32_t i=0; i<WAV_COUNT; ++i)
7389 {
7390 //allegro assertion fails when passing in -1 as voice -DD
7391 if(sfx_voice[i] > 0)
7392 voice_set_volume(sfx_voice[i], sfx_volume);
7393 }
7394 }
7395 else
7396 {
7397 midi_volume = m;
7398 digi_volume = d;
7399 emusic_volume = e;
7400 zcmusic_bufsz = b;
7401 sfx_volume = s;
7402 pan_style = p;
7403 }
7404
7405 save_game_configs();
7406 return D_O_K;
7407 }
7408
7409 int32_t queding(char const* s1, char const* s2, char const* s3)
7410 {
7411 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',lfont);
7412 }
7413
7414 int32_t onQuit()
7415 {
7416 if(Playing)
7417 {
7418 int32_t ret=0;
7419
7420 if(get_bit(quest_rules, qr_NOCONTINUE))
7421 {
7422 if(standalone_mode)
7423 {
7424 ret=queding("End current game?",
7425 "The continue screen is disabled; the game",
7426 "will be reloaded from the last save.");
7427 }
7428 else
7429 {
7430 ret=queding("End current game?",
7431 "The continue screen is disabled. You will",
7432 "be returned to the file select screen.");
7433 }
7434 }
7435 else
7436 ret=queding("End current game?",NULL,NULL);
7437
7438 if(ret==1)
7439 {
7440 disableClickToFreeze=false;
7441 Quit=qQUIT;
7442
7443 // Trying to evade a door repair charge?
7444 if(repaircharge)
7445 {
7446 game->change_drupy(-repaircharge);
7447 repaircharge=0;
7448 }
7449
7450 return D_CLOSE;
7451 }
7452 }
7453
7454 return D_O_K;
7455 }
7456
7457 int32_t onTryQuitMenu()
7458 {
7459 return onTryQuit(true);
7460 }
7461
7462 int32_t onTryQuit(bool inMenu)
7463 {
7464 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7465 {
7466 if(get_bit(quest_rules,qr_OLD_F6))
7467 {
7468 if(inMenu) onQuit();
7469 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7470 }
7471 else
7472 {
7473 disableClickToFreeze=false;
7474 GameFlags |= GAMEFLAG_TRYQUIT;
7475 }
7476 return D_CLOSE;
7477 }
7478
7479 return D_O_K;
7480 }
7481
7482 int32_t onReset()
7483 {
7484 if(queding(" Reset system? ",NULL,NULL)==1)
7485 {
7486 disableClickToFreeze=false;
7487 Quit=qRESET;
7488 replay_quit();
7489 return D_CLOSE;
7490 }
7491
7492 return D_O_K;
7493 }
7494
7495 int32_t onExit()
7496 {
7497 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7498 {
7499 Quit=qEXIT;
7500 return D_CLOSE;
7501 }
7502
7503 return D_O_K;
7504 }
7505
7506 int32_t onTitle_NES()
7507 {
7508 title_version=0;
7509 return D_O_K;
7510 }
7511 int32_t onTitle_DX()
7512 {
7513 title_version=1;
7514 return D_O_K;
7515 }
7516 int32_t onTitle_25()
7517 {
7518 title_version=2;
7519 return D_O_K;
7520 }
7521
7522 int32_t onDebug()
7523 {
7524 if(debug_enabled)
7525 set_debug(!get_debug());
7526 save_game_configs();
7527 return D_O_K;
7528 }
7529
7530 int32_t onHeartBeep()
7531 {
7532 heart_beep=!heart_beep;
7533 save_game_configs();
7534 return D_O_K;
7535 }
7536
7537 int32_t onSaveIndicator()
7538 {
7539 use_save_indicator=!use_save_indicator;
7540 save_game_configs();
7541 return D_O_K;
7542 }
7543
7544 int32_t onEpilepsy()
7545 {
7546 if(jwin_alert3(
7547 "Epilepsy Flash Reduction",
7548 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7549 "Disabling this will restore standard flash and wavy behaviour.",
7550 "Proceed?",
7551 "&Yes",
7552 "&No",
7553 NULL,
7554 'y',
7555 'n',
7556 0,
7557 lfont) == 1)
7558 {
7559 if ( epilepsyFlashReduction ) epilepsyFlashReduction = 0;
7560 else epilepsyFlashReduction = 1;
7561 set_config_int("zeldadx","checked_epilepsy",1);
7562 save_game_configs();
7563 }
7564 return D_O_K;
7565 }
7566
7567 int32_t onTriforce()
7568 {
7569 for(int32_t i=0; i<MAXINITTABS; ++i)
7570 {
7571 init_tabs[i].flags&=~D_SELECTED;
7572 }
7573
7574 init_tabs[3].flags=D_SELECTED;
7575 return onCheatConsole();
7576 /*triforce_dlg[0].dp2=lfont;
7577 for(int32_t i=1; i<=8; i++)
7578 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7579
7580 if(zc_popup_dialog (triforce_dlg,-1)==9)
7581 {
7582 for(int32_t i=1; i<=8; i++)
7583 {
7584 game->lvlitems[i] &= ~liTRIFORCE;
7585 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7586 }
7587 }
7588 return D_O_K;*/
7589 }
7590
7591 bool rc = false;
7592 /*
7593 int32_t onEquipment()
7594 {
7595 for (int32_t i=0; i<MAXINITTABS; ++i)
7596 {
7597 init_tabs[i].flags&=~D_SELECTED;
7598 }
7599 init_tabs[0].flags=D_SELECTED;
7600 return onCheatConsole();
7601 }
7602 */
7603
7604 int32_t onItems()
7605 {
7606 for(int32_t i=0; i<MAXINITTABS; ++i)
7607 {
7608 init_tabs[i].flags&=~D_SELECTED;
7609 }
7610
7611 init_tabs[1].flags=D_SELECTED;
7612 return onCheatConsole();
7613 }
7614
7615 static DIALOG getnum_dlg[] =
7616 {
7617 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7618 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7619 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7620 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7621 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7622 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7623 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7624 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7625 };
7626
7627 int32_t getnumber(const char *prompt,int32_t initialval)
7628 {
7629 char buf[20];
7630 sprintf(buf,"%d",initialval);
7631 getnum_dlg[0].dp=(void *)prompt;
7632 getnum_dlg[0].dp2=lfont;
7633 getnum_dlg[2].dp=buf;
7634
7635 if(is_large)
7636 large_dialog(getnum_dlg);
7637
7638 if(zc_popup_dialog(getnum_dlg,2)==3)
7639 return atoi(buf);
7640
7641 return initialval;
7642 }
7643
7644 int32_t onLife()
7645 {
7646 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7647 cheats_enqueue(Cheat::Life, value);
7648 return D_O_K;
7649 }
7650
7651 int32_t onHeartC()
7652 {
7653 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7654 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7655 cheats_enqueue(Cheat::MaxLife, max_life);
7656 cheats_enqueue(Cheat::Life, life);
7657 return D_O_K;
7658 }
7659
7660 int32_t onMagicC()
7661 {
7662 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7663 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7664 cheats_enqueue(Cheat::MaxMagic, max_magic);
7665 cheats_enqueue(Cheat::Magic, magic);
7666 return D_O_K;
7667 }
7668
7669 int32_t onRupies()
7670 {
7671 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7672 cheats_enqueue(Cheat::Rupies, value);
7673 return D_O_K;
7674 }
7675
7676 int32_t onMaxBombs()
7677 {
7678 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7679 cheats_enqueue(Cheat::MaxBombs, value);
7680 cheats_enqueue(Cheat::Bombs, value);
7681 return D_O_K;
7682 }
7683
7684 int32_t onRefillLife()
7685 {
7686 cheats_enqueue(Cheat::Life, game->get_maxlife());
7687 return D_O_K;
7688 }
7689 int32_t onRefillMagic()
7690 {
7691 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7692 return D_O_K;
7693 }
7694 int32_t onClock()
7695 {
7696 cheats_enqueue(Cheat::Clock);
7697 return D_O_K;
7698 }
7699
7700 int32_t onQstPath()
7701 {
7702 char path[2048];
7703
7704 chop_path(qstdir);
7705 strcpy(path,qstdir);
7706
7707 go();
7708
7709 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, lfont))
7710 {
7711 chop_path(path);
7712 fix_filename_case(path);
7713 fix_filename_slashes(path);
7714 strcpy(qstdir,path);
7715 strcpy(qstpath,qstdir);
7716 }
7717
7718 comeback();
7719 return D_O_K;
7720 }
7721
7722 #include "dialog/cheat_dialog.h"
7723 int32_t onCheat()
7724 {
7725 call_setcheat_dialog();
7726 game->set_cheat(maxcheat);
7727 if(cheat) game->did_cheat(true);
7728 return D_O_K;
7729 }
7730
7731 int32_t onCheatRupies()
7732 {
7733 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7734 return D_O_K;
7735 }
7736
7737 int32_t onCheatArrows()
7738 {
7739 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7740 return D_O_K;
7741 }
7742
7743 int32_t onCheatBombs()
7744 {
7745 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7746 return D_O_K;
7747 }
7748
7749 // *** screen saver
7750
7751 710160 int32_t after_time()
7752 {
7753
1/2
✓ Branch 0 taken 710160 times.
✗ Branch 1 not taken.
710160 if(ss_enable == 0)
7754 return INT_MAX;
7755
7756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 710160 times.
710160 if(ss_after <= 0)
7757 return 5 * 60;
7758
7759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 710160 times.
710160 if(ss_after <= 3)
7760 return ss_after * 15 * 60;
7761
7762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 710160 times.
710160 if(ss_after <= 13)
7763 return (ss_after - 3) * 60 * 60;
7764
7765 710160 return MAX_IDLE + 1;
7766 710160 }
7767
7768 static const char *after_str[15] =
7769 {
7770 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7771 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7772 "Never"
7773 };
7774
7775 const char *after_list(int32_t index, int32_t *list_size)
7776 {
7777 if(index < 0)
7778 {
7779 *list_size = 15;
7780 return NULL;
7781 }
7782
7783 return after_str[index];
7784 }
7785
7786 9 static ListData after__list(after_list, &font);
7787
7788 static DIALOG scrsaver_dlg[] =
7789 {
7790 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7791 9 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7792 9 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7793 9 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7794 9 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7795 9 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7796 9 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7797 9 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7798 9 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7799 9 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7800 9 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7801 9 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7802 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7803 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7804 };
7805
7806 int32_t onScreenSaver()
7807 {
7808 scrsaver_dlg[0].dp2=lfont;
7809 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = ss_after;
7810 scrsaver_dlg[6].d2 = ss_speed;
7811 scrsaver_dlg[7].d2 = ss_density;
7812
7813 if(is_large)
7814 large_dialog(scrsaver_dlg);
7815
7816 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7817
7818 if(ret == 8 || ret == 9)
7819 {
7820 ss_after = scrsaver_dlg[5].d1;
7821 ss_speed = scrsaver_dlg[6].d2;
7822 ss_density = scrsaver_dlg[7].d2;
7823 }
7824
7825 if(ret == 9)
7826 // preview Screen Saver
7827 {
7828 clear_keybuf();
7829 scare_mouse();
7830 Matrix(ss_speed, ss_density, 30);
7831 system_pal();
7832 unscare_mouse();
7833 }
7834
7835 return D_O_K;
7836 }
7837
7838 /***** Menus *****/
7839
7840 static MENU game_menu[] =
7841 {
7842 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7843 { (char *)"", NULL, NULL, 0, NULL },
7844 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7845 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7846 { (char *)"", NULL, NULL, 0, NULL },
7847 #ifdef __EMSCRIPTEN__
7848 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7849 #elif defined(ALLEGRO_MACOSX)
7850 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7851 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7852 #else
7853 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7854 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7855 #endif
7856 { NULL, NULL, NULL, 0, NULL }
7857 };
7858
7859 static MENU title_menu[] =
7860 {
7861 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7862 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7863 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7864 { NULL, NULL, NULL, 0, NULL }
7865 };
7866
7867 static MENU snapshot_format_menu[] =
7868 {
7869 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7870 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7871 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7872 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7873 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7874 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7875 { NULL, NULL, NULL, 0, NULL }
7876 };
7877
7878 static MENU controls_menu[] =
7879 {
7880 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7881 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7882 { NULL, NULL, NULL, 0, NULL }
7883 };
7884
7885 static MENU name_entry_mode_menu[] =
7886 {
7887 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7888 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7889 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7890 { NULL, NULL, NULL, 0, NULL }
7891 };
7892
7893 static void set_controls_menu_active()
7894 {
7895
7896 }
7897
7898 static MENU settings_menu[] =
7899 {
7900 { (char *)"&Sound...", onSound, NULL, 0, NULL },
7901 { (char *)"C&ontrols", NULL, controls_menu, 0, NULL },
7902 { (char *)"&Title Screen", NULL, title_menu, 0, NULL },
7903 { (char *)"Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7904 { (char *)"", NULL, NULL, 0, NULL },
7905 { (char *)"&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7906 { (char *)"Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7907 { (char *)"Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7908 { (char *)"Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7909 { (char *)"Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7910 { (char *)"Autosave Window Size Changes", onSaveDragResize, NULL, 0, NULL },
7911 { (char *)"Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7912 { (char *)"Window Position Saving", onWinPosSave, NULL, 0, NULL },
7913 { (char *)"Volume &Keys", onVolKeys, NULL, 0, NULL },
7914 { (char *)"Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7915 { (char *)"Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7916 { (char *)"Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7917 { (char *)"S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7918 { (char *)"", NULL, NULL, 0, NULL },
7919 { (char *)"Debu&g", onDebug, NULL, 0, NULL },
7920 { (char *)"", NULL, NULL, 0, NULL },
7921 { NULL, NULL, NULL, 0, NULL }
7922 };
7923
7924
7925 static MENU misc_menu[] =
7926 {
7927 { (char *)"&About...", onAbout, NULL, 0, NULL },
7928 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7929 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7930 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7931 { (char *)"", NULL, NULL, 0, NULL },
7932 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7933 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7934 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7935 { (char *)"", NULL, NULL, 0, NULL },
7936 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7937 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7938 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7939 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7940 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7941 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7942 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7943 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7944
7945 { NULL, NULL, NULL, 0, NULL }
7946 };
7947
7948 static MENU refill_menu[] =
7949 {
7950 { (char *)"&Life\t*, H", onRefillLife, NULL, 0, NULL },
7951 { (char *)"&Magic\t/, M", onRefillMagic, NULL, 0, NULL },
7952 { (char *)"&Bombs\tB", onCheatBombs, NULL, 0, NULL },
7953 { (char *)"&Rupees\tR", onCheatRupies, NULL, 0, NULL },
7954 { (char *)"&Arrows\tA", onCheatArrows, NULL, 0, NULL },
7955 { NULL, NULL, NULL, 0, NULL }
7956 };
7957
7958 static MENU show_menu[] =
7959 {
7960 { (char *)"Combos\t0", onShowLayer0, NULL, 0, NULL },
7961 { (char *)"Layer 1\t1", onShowLayer1, NULL, 0, NULL },
7962 { (char *)"Layer 2\t2", onShowLayer2, NULL, 0, NULL },
7963 { (char *)"Layer 3\t3", onShowLayer3, NULL, 0, NULL },
7964 { (char *)"Layer 4\t4", onShowLayer4, NULL, 0, NULL },
7965 { (char *)"Layer 5\t5", onShowLayer5, NULL, 0, NULL },
7966 { (char *)"Layer 6\t6", onShowLayer6, NULL, 0, NULL },
7967 { (char *)"Overhead Combos\tO", onShowLayerO, NULL, 0, NULL },
7968 { (char *)"Push Blocks\tP", onShowLayerP, NULL, 0, NULL },
7969 { (char *)"Freeform Combos\t7", onShowLayerF, NULL, 0, NULL },
7970 { (char *)"Sprites\t8", onShowLayerS, NULL, 0, NULL },
7971 { (char *)"", NULL, NULL, 0, NULL },
7972 { (char *)"Walkability\tW", onShowLayerW, NULL, 0, NULL },
7973 { (char *)"Current FFC Scripts\tF", onShowFFScripts, NULL, 0, NULL },
7974 { (char *)"Hitboxes\tC", onShowHitboxes, NULL, 0, NULL },
7975 { (char *)"Effects\tE", onShowLayerE, NULL, 0, NULL },
7976 { NULL, NULL, NULL, 0, NULL }
7977 };
7978
7979 static MENU cheat_menu[] =
7980 {
7981 { (char *)"S&et Cheat", onCheat, NULL, 0, NULL },
7982 { (char *)"", NULL, NULL, 0, NULL },
7983 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7984 { (char *)"", NULL, NULL, 0, NULL },
7985 { (char *)"&Clock\tI", onClock, NULL, 0, NULL },
7986 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7987 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7988 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7989 { (char *)"", NULL, NULL, 0, NULL },
7990 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7991 { (char *)"", NULL, NULL, 0, NULL },
7992 { (char *)"Walk Through &Walls\tF11", onNoWalls, NULL, 0, NULL },
7993 { (char *)"Player Ignores Side&view\tV", onIgnoreSideview, NULL, 0, NULL },
7994 { (char *)"&Quick Movement\tQ", onGoFast, NULL, 0, NULL },
7995 { (char *)"&Kill All Enemies\tK", onKillCheat, NULL, 0, NULL },
7996 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7997 { (char *)"Toggle Light\tL", onLightSwitch, NULL, 0, NULL },
7998 { (char *)"&Goto Location...\tG", onGoTo, NULL, 0, NULL },
7999 { NULL, NULL, NULL, 0, NULL }
8000 };
8001
8002 static MENU fixes_menu[] =
8003 {
8004 { (char *)"Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
8005 { NULL, NULL, NULL, 0, NULL }
8006 };
8007
8008 #if DEVLEVEL > 0
8009 int32_t devLogging();
8010 int32_t devDebug();
8011 int32_t devTimestmp();
8012 #if DEVLEVEL > 1
8013 int32_t setCheat();
8014 #endif //DEVLEVEL > 1
8015 enum
8016 {
8017 dv_log,
8018 // dv_dbg,
8019 dv_tmpstmp,
8020 #if DEVLEVEL > 1
8021 dv_nil,
8022 dv_setcheat,
8023 #endif //DEVLEVEL > 1
8024 dv_max
8025 };
8026 static MENU dev_menu[] =
8027 {
8028 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
8029 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
8030 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
8031 #if DEVLEVEL > 1
8032 { (char *)"", NULL, NULL, 0, NULL },
8033 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
8034 #endif //DEVLEVEL > 1
8035 { NULL, NULL, NULL, 0, NULL }
8036 };
8037 int32_t devLogging()
8038 {
8039 dev_logging = !dev_logging;
8040 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
8041 return D_O_K;
8042 }
8043 // int32_t devDebug()
8044 // {
8045 // dev_debug = !dev_debug;
8046 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
8047 // return D_O_K;
8048 // }
8049 int32_t devTimestmp()
8050 {
8051 dev_timestmp = !dev_timestmp;
8052 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
8053 return D_O_K;
8054 }
8055 #if DEVLEVEL > 1
8056 int32_t setCheat()
8057 {
8058 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
8059 return D_O_K;
8060 }
8061 #endif //DEVLEVEL > 1
8062 #endif //DEVLEVEL > 0
8063
8064 MENU the_player_menu[] =
8065 {
8066 { (char *)"&Game", NULL, game_menu, 0, NULL },
8067 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8068 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
8069 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8070 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8071 #if DEVLEVEL > 0
8072 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8073 #endif
8074 { NULL, NULL, NULL, 0, NULL }
8075 };
8076
8077 MENU the_player_menu2[] =
8078 {
8079 { (char *)"&Game", NULL, game_menu, 0, NULL },
8080 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8081 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8082 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8083 #if DEVLEVEL > 0
8084 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8085 #endif
8086 { NULL, NULL, NULL, 0, NULL }
8087 };
8088
8089 int32_t onMIDIPatch()
8090 {
8091 if(jwin_alert3(
8092 "Toggle Windows MIDI Fix",
8093 "This action will change whether ZC Player auto-restarts a MIDI at its",
8094 "last index if you move ZC Player out of focus, then back into focus.",
8095 "Proceed?",
8096 "&Yes",
8097 "&No",
8098 NULL,
8099 'y',
8100 'n',
8101 0,
8102 lfont) == 1)
8103 {
8104 if (midi_patch_fix) midi_patch_fix = 0;
8105
8106 else midi_patch_fix = 1;
8107
8108 }
8109 fixes_menu[0].flags =(midi_patch_fix)?D_SELECTED:0;
8110 save_game_configs();
8111 return D_O_K;
8112 }
8113
8114 int32_t onKeyboardEntry()
8115 {
8116 NameEntryMode=0;
8117 return D_O_K;
8118 }
8119
8120 int32_t onLetterGridEntry()
8121 {
8122 NameEntryMode=1;
8123 return D_O_K;
8124 }
8125
8126 int32_t onExtLetterGridEntry()
8127 {
8128 NameEntryMode=2;
8129 return D_O_K;
8130 }
8131
8132 static BITMAP* oldscreen;
8133 int32_t onFullscreenMenu()
8134 {
8135 // super hacks
8136 screen = oldscreen;
8137 if (onFullscreen() == D_REDRAW)
8138 {
8139 oldscreen = screen;
8140 }
8141 screen = menu_bmp;
8142 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8143 return D_O_K;
8144 }
8145
8146 9 void fix_menu()
8147 {
8148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!debug_enabled)
8149 9 settings_menu[18].text = NULL;
8150 9 }
8151
8152 static DIALOG system_dlg[] =
8153 {
8154 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8155 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
8156 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8157 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8158 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8159 #ifndef ALLEGRO_MACOSX
8160 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8161 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8162 #else
8163 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8164 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8165 #endif
8166 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8167 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8168 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8169 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8170 };
8171
8172 static DIALOG system_dlg2[] =
8173 {
8174 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8175 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu2, NULL, NULL },
8176 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8177 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8178 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8179 #ifndef ALLEGRO_MACOSX
8180 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8181 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8182 #else
8183 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8184 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8185 #endif
8186 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8187 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8188 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8189 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8190 };
8191
8192 void reset_snapshot_format_menu()
8193 {
8194 for(int32_t i=0; i<ssfmtMAX; ++i)
8195 {
8196 snapshot_format_menu[i].flags=0;
8197 }
8198 }
8199
8200 int32_t onSetSnapshotFormat()
8201 {
8202 switch(active_menu->text[1])
8203 {
8204 case 'B': //"&BMP"
8205 SnapshotFormat=0;
8206 break;
8207
8208 case 'G': //"&GIF"
8209 SnapshotFormat=1;
8210 break;
8211
8212 case 'J': //"&JPG"
8213 SnapshotFormat=2;
8214 break;
8215
8216 case 'P': //"&PNG"
8217 SnapshotFormat=3;
8218 break;
8219
8220 case 'C': //"PC&X"
8221 SnapshotFormat=4;
8222 break;
8223
8224 case 'T': //"&TGA"
8225 SnapshotFormat=5;
8226 break;
8227
8228 case 'L': //"&LBM"
8229 SnapshotFormat=6;
8230 break;
8231 }
8232
8233 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
8234 return D_O_K;
8235 }
8236
8237
8238 10 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
8239 {
8240 PALETTE tmp;
8241
8242
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 10 times.
2570 for(int32_t i=0; i<256; i++)
8243 {
8244 2560 tmp[i].r=r;
8245 2560 tmp[i].g=g;
8246 2560 tmp[i].b=b;
8247 2560 }
8248
8249 10 fade_interpolate(src,tmp,dest,pos,from,to);
8250 10 }
8251
8252 10 void system_pal()
8253 {
8254 10 is_sys_pal = true;
8255 static PALETTE pal;
8256 10 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
8257
8258 // set up the grayscale palette
8259
2/2
✓ Branch 0 taken 640 times.
✓ Branch 1 taken 10 times.
650 for(int32_t i=128; i<192; i++)
8260 {
8261 640 pal[i].r = i-128;
8262 640 pal[i].g = i-128;
8263 640 pal[i].b = i-128;
8264 640 }
8265 10 load_colorset(gui_colorset, pal);
8266
8267 10 color_layer(pal, pal, 24,16,16, 28, 128,191);
8268
8269
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 10 times.
1290 for(int32_t i=0; i<256; i+=2)
8270 {
8271 1280 int32_t v = (i>>3)+2;
8272 1280 int32_t c = (i>>3)+192;
8273 1280 pal[c] = _RGB(v,v,v+(v>>1));
8274 /*
8275 if(i<240)
8276 {
8277 _allegro_hline(tmp_scr,0,i,319,c);
8278 _allegro_hline(tmp_scr,0,i+1,319,c);
8279 }
8280 */
8281 1280 }
8282
8283 // draw the vertical screen gradient
8284
2/2
✓ Branch 0 taken 2400 times.
✓ Branch 1 taken 10 times.
2410 for(int32_t i=0; i<240; ++i)
8285 {
8286 2400 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8287 2400 }
8288
8289 /*
8290 palrstart= 10*63/255; palrend=166*63/255;
8291 palgstart= 36*63/255; palgend=202*63/255;
8292 palbstart=106*63/255; palbend=240*63/255;
8293 paldivs=32;
8294 for(int32_t i=0; i<paldivs; i++)
8295 {
8296 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8297 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8298 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8299 }
8300 */
8301 10 BITMAP *panorama = create_bitmap_ex(8,256,224);
8302 int32_t ts_height, ts_start;
8303
8304
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8305 {
8306 clear_to_color(panorama,0);
8307 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8308 ts_height=224-passive_subscreen_height;
8309 ts_start=28;
8310 }
8311 else
8312 {
8313 10 blit(framebuf,panorama,0,0,0,0,256,224);
8314 10 ts_height=224;
8315 10 ts_start=0;
8316 }
8317
8318 // gray scale the current frame
8319
2/2
✓ Branch 0 taken 2240 times.
✓ Branch 1 taken 10 times.
2250 for(int32_t y=0; y<ts_height; y++)
8320 {
8321
2/2
✓ Branch 0 taken 573440 times.
✓ Branch 1 taken 2240 times.
575680 for(int32_t x=0; x<256; x++)
8322 {
8323 573440 int32_t c = panorama->line[y+ts_start][x];
8324
2/2
✓ Branch 0 taken 572959 times.
✓ Branch 1 taken 481 times.
573440 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
8325 573440 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8326 573440 }
8327 2240 }
8328
8329 10 destroy_bitmap(panorama);
8330
8331 // display everything
8332 10 vsync();
8333 10 hw_palette = &pal;
8334 10 update_hw_pal = true;
8335
8336 // sys_pal = pal;
8337 10 memcpy(sys_pal,pal,sizeof(pal));
8338 10 }
8339
8340 void system_pal2()
8341 {
8342 is_sys_pal = true;
8343 static PALETTE RAMpal2;
8344 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8345
8346 /* Windows 2000 colors
8347 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8348 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8349 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8350 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8351 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8352 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8353 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8354 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8355
8356 byte palrstart= 10*63/255, palrend=166*63/255,
8357 palgstart= 36*63/255, palgend=202*63/255,
8358 palbstart=106*63/255, palbend=240*63/255,
8359 paldivs=7;
8360 for(int32_t i=0; i<paldivs; i++)
8361 {
8362 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8363 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8364 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8365 }
8366 */
8367
8368 /* Windows 98 colors
8369 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8370 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8371 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8372 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8373 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8374 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8375 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8376 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8377
8378 byte palrstart= 0*63/255, palrend=166*63/255,
8379 palgstart= 0*63/255, palgend=202*63/255,
8380 palbstart=128*63/255, palbend=240*63/255,
8381 paldivs=7;
8382 for(int32_t i=0; i<paldivs; i++)
8383 {
8384 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8385 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8386 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8387 }
8388 */
8389
8390 /* Windows 99 colors
8391 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8392 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8393 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8394 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8395 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8396 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8397 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8398 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8399 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8400
8401 byte palrstart= 0*63/255, palrend=166*63/255,
8402 palgstart= 0*63/255, palgend=202*63/255,
8403
8404 palbstart=128*63/255, palbend=240*63/255,
8405 paldivs=6;
8406 for(int32_t i=0; i<paldivs; i++)
8407 {
8408 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8409 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8410 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8411 }
8412 */
8413
8414
8415
8416 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8417 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8418 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8419 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8420 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8421 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8422 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8423 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8424 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8425
8426 byte palrstart= 0*63/255, palrend=166*63/255,
8427 palgstart= 0*63/255, palgend=202*63/255,
8428 palbstart=128*63/255, palbend=240*63/255,
8429 paldivs=6;
8430
8431 for(int32_t i=0; i<paldivs; i++)
8432 {
8433 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8434 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8435 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8436 }
8437
8438 gui_bg_color=jwin_pal[jcBOX];
8439 gui_fg_color=jwin_pal[jcBOXFG];
8440
8441 jwin_set_colors(jwin_pal);
8442
8443
8444 // set up the new palette
8445 for(int32_t i=128; i<192; i++)
8446 {
8447 RAMpal2[i].r = i-128;
8448 RAMpal2[i].g = i-128;
8449 RAMpal2[i].b = i-128;
8450 }
8451
8452 /*
8453 for(int32_t i=0; i<64; i++)
8454 {
8455 RAMpal2[128+i] = _RGB(i,i,i)1));
8456 }
8457 */
8458
8459 /*
8460
8461 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8462 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8463 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8464 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8465 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8466 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8467 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8468
8469 gui_fg_color=vc(14);
8470 gui_bg_color=vc(1);
8471
8472 jwin_set_colors(jwin_pal);
8473 */
8474
8475 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8476
8477 // set up the colors for the vertical screen gradient
8478 for(int32_t i=0; i<256; i+=2)
8479 {
8480 int32_t v = (i>>3)+2;
8481 int32_t c = (i>>3)+192;
8482 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8483
8484 /*
8485 if(i<240)
8486 {
8487 _allegro_hline(tmp_scr,0,i,319,c);
8488 _allegro_hline(tmp_scr,0,i+1,319,c);
8489 }
8490 */
8491 }
8492
8493 // hw_palette = &RAMpal;
8494 // update_hw_pal = true;
8495
8496 for(int32_t i=0; i<240; ++i)
8497 {
8498 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8499 }
8500
8501 /*
8502 byte palrstart= 10*63/255, palrend=166*63/255,
8503 palgstart= 36*63/255, palgend=202*63/255,
8504 palbstart=106*63/255, palbend=240*63/255,
8505 paldivs=32;
8506 for(int32_t i=0; i<paldivs; i++)
8507 {
8508 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8509 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8510 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8511 }
8512 */
8513 BITMAP *panorama = create_bitmap_ex(8,256,224);
8514 int32_t ts_height, ts_start;
8515
8516 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8517 {
8518 clear_to_color(panorama,0);
8519 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8520 ts_height=224-passive_subscreen_height;
8521 ts_start=28;
8522 }
8523 else
8524 {
8525 blit(framebuf,panorama,0,0,0,0,256,224);
8526 ts_height=224;
8527 ts_start=0;
8528 }
8529
8530 // gray scale the current frame
8531 for(int32_t y=0; y<ts_height; y++)
8532 {
8533 for(int32_t x=0; x<256; x++)
8534 {
8535 int32_t c = panorama->line[y+ts_start][x];
8536 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8537 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8538 }
8539 }
8540
8541 destroy_bitmap(panorama);
8542
8543 // display everything
8544 vsync();
8545 hw_palette = &RAMpal2;
8546 update_hw_pal = true;
8547
8548 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8549
8550 // sys_pal = pal;
8551 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8552 }
8553
8554 static uint32_t entered_sys_pal = 0;
8555 1 void enter_sys_pal()
8556 {
8557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(is_sys_pal)
8558 {
8559 if(entered_sys_pal)
8560 ++entered_sys_pal;
8561 return;
8562 }
8563 1 system_pal();
8564 1 ++entered_sys_pal;
8565 1 }
8566 1 void exit_sys_pal()
8567 {
8568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(entered_sys_pal)
8569 {
8570
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!--entered_sys_pal)
8571 {
8572 1 game_pal();
8573 1 }
8574 1 }
8575 1 }
8576
8577 1 void switch_out_callback()
8578 {
8579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (pause_in_background)
8580 {
8581 callback_switchin = 3;
8582 return;
8583 }
8584
8585 #ifdef _WIN32
8586 if(midi_patch_fix==0 || currmidi==-1)
8587 return;
8588
8589
8590 paused_midi_pos = midi_pos;
8591 zc_stop_midi();
8592 midi_paused=true;
8593 midi_suspended = midissuspHALTED;
8594 #endif
8595 1 }
8596
8597 void switch_in_callback()
8598 {
8599 zc_update_builtin_font();
8600
8601 if(pause_in_background)
8602 {
8603 return;
8604 }
8605
8606 #ifdef _WIN32
8607 if(midi_patch_fix==0 || currmidi==-1)
8608 return;
8609
8610 else
8611 {
8612 callback_switchin = 1;
8613 midi_suspended = midissuspRESUME;
8614 }
8615 #endif
8616 }
8617
8618 43 void game_pal()
8619 {
8620 43 is_sys_pal = false;
8621 43 entered_sys_pal = 0;
8622 43 clear_to_color(screen,BLACK);
8623 43 hw_palette = &RAMpal;
8624 43 update_hw_pal = true;
8625 43 }
8626
8627 static char bar_str[] = "";
8628
8629 1 void music_pause()
8630 {
8631 //al_pause_duh(tmplayer);
8632 1 zcmusic_pause(zcmusic, ZCM_PAUSE);
8633 1 zc_midi_pause();
8634 1 midi_paused=true;
8635 1 }
8636
8637 void music_resume()
8638 {
8639 //al_resume_duh(tmplayer);
8640 zcmusic_pause(zcmusic, ZCM_RESUME);
8641 zc_midi_resume();
8642 midi_paused=false;
8643 }
8644
8645 478 void music_stop()
8646 {
8647 //al_stop_duh(tmplayer);
8648 //unload_duh(tmusic);
8649 //tmusic=NULL;
8650 //tmplayer=NULL;
8651 478 zcmusic_stop(zcmusic);
8652 478 zcmusic_unload_file(zcmusic);
8653 478 zc_stop_midi();
8654 478 midi_paused=false;
8655 478 currmidi=-1;
8656 478 }
8657
8658 void System()
8659 {
8660 mouse_down=gui_mouse_b();
8661 music_pause();
8662 pause_all_sfx();
8663 MenuOpen = true;
8664 system_pal();
8665 // FONT *oldfont=font;
8666 // font=tfont;
8667
8668 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8669 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8670
8671 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8672 #if DEVLEVEL > 1
8673 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8674 #endif
8675 game_menu[3].flags =
8676 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8677 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8678 fixes_menu[0].flags = (midi_patch_fix)?D_SELECTED:0;
8679 clear_keybuf();
8680 show_mouse(screen);
8681
8682 DIALOG_PLAYER *p;
8683
8684 clear_bitmap(menu_bmp);
8685 oldscreen = screen;
8686 screen = menu_bmp;
8687
8688 if(!Playing || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode))
8689 {
8690 p = init_dialog(system_dlg2,-1);
8691 }
8692 else
8693 {
8694 p = init_dialog(system_dlg,-1);
8695 }
8696
8697 // drop the menu on startup if menu button pressed
8698 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8699 simulate_keypress(KEY_G << 8);
8700
8701 do
8702 {
8703 if(close_button_quit)
8704 {
8705 close_button_quit = false;
8706 f_Quit(qEXIT);
8707 if(Quit) break;
8708 }
8709 rest(17);
8710
8711 if(mouse_down && !gui_mouse_b())
8712 mouse_down=0;
8713
8714 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8715 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8716 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8717
8718 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8719 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8720 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8721 settings_menu[7].flags = TransLayers?D_SELECTED:0;
8722 settings_menu[8].flags = NESquit?D_SELECTED:0;
8723 settings_menu[9].flags = ClickToFreeze?D_SELECTED:0;
8724 settings_menu[10].flags = SaveDragResize?D_SELECTED:0;
8725 settings_menu[11].flags = DragAspect?D_SELECTED:0;
8726 settings_menu[12].flags = SaveWinPos?D_SELECTED:0;
8727 settings_menu[13].flags = volkeys?D_SELECTED:0;
8728 //Epilepsy Prevention
8729 settings_menu[16].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8730
8731 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8732 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8733 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8734
8735 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8736 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8737
8738 the_player_menu[2].flags = replay_is_replaying() ? D_DISABLED : 0;
8739 cheat_menu[0].flags = 0;
8740 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8741 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8742 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8743 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8744 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8745 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8746 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8747 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8748 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8749
8750 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8751 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8752 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8753 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8754 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8755 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8756 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8757 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8758 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8759 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8760 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8761 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8762 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8763 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8764 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8765
8766 settings_menu[14].flags = heart_beep ? D_SELECTED : 0;
8767 settings_menu[15].flags = use_save_indicator ? D_SELECTED : 0;
8768
8769 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8770 (char *)"Disable recording new saves" :
8771 (char *)"Enable recording new saves";
8772 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8773 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8774 (char *)"Stop recording" :
8775 (char *)"Stop replaying";
8776 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8777
8778 reset_snapshot_format_menu();
8779 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8780
8781 if(debug_enabled)
8782 {
8783 settings_menu[19].flags = get_debug() ? D_SELECTED : 0;
8784 }
8785
8786 if(gui_mouse_b() && !mouse_down)
8787 break;
8788
8789 // press menu to drop the menu
8790 if(rMbtn())
8791 simulate_keypress(KEY_G << 8);
8792
8793 if(input_idle(true) > after_time())
8794 // run Screeen Saver
8795 {
8796 // Screen saver enabled for now.
8797 clear_keybuf();
8798 scare_mouse();
8799 Matrix(ss_speed, ss_density, 0);
8800 system_pal();
8801 unscare_mouse();
8802 broadcast_dialog_message(MSG_DRAW, 0);
8803 }
8804
8805 update_hw_screen();
8806 }
8807 while(update_dialog(p));
8808
8809 screen = oldscreen;
8810
8811 // font=oldfont;
8812 mouse_down=gui_mouse_b();
8813 shutdown_dialog(p);
8814 show_mouse(NULL);
8815 MenuOpen = false;
8816 if(Quit)
8817 {
8818 kill_sfx();
8819 music_stop();
8820 update_hw_screen();
8821 }
8822 else
8823 {
8824 game_pal();
8825 music_resume();
8826 resume_all_sfx();
8827
8828 if(rc)
8829 ringcolor(false);
8830 }
8831
8832 eat_buttons();
8833
8834 rc=false;
8835 clear_keybuf();
8836 // text_mode(0);
8837 }
8838
8839 9 void fix_dialogs()
8840 {
8841 9 jwin_center_dialog(about_dlg);
8842 9 jwin_center_dialog(gamepad_dlg);
8843 9 jwin_center_dialog(credits_dlg);
8844 9 jwin_center_dialog(gamemode_dlg);
8845 9 jwin_center_dialog(getnum_dlg);
8846 9 jwin_center_dialog(goto_dlg);
8847 9 jwin_center_dialog(keyboard_control_dlg);
8848 9 jwin_center_dialog(midi_dlg);
8849 9 jwin_center_dialog(quest_dlg);
8850 9 jwin_center_dialog(scrsaver_dlg);
8851 9 jwin_center_dialog(sound_dlg);
8852 9 jwin_center_dialog(triforce_dlg);
8853
8854 // digi_dp[1] += scrx;
8855 // digi_dp[2] += scry;
8856 // midi_dp[1] += scrx;
8857 // midi_dp[2] += scry;
8858 // pan_dp[1] += scrx;
8859 // pan_dp[2] += scry;
8860 // emus_dp[1] += scrx;
8861 // emus_dp[2] += scry;
8862 // buf_dp[1] += scrx;
8863 // buf_dp[2] += scry;
8864 // sfx_dp[1] += scrx;
8865 // sfx_dp[2] += scry;
8866 9 }
8867
8868 /*****************************/
8869 /**** Custom Sound System ****/
8870 /*****************************/
8871
8872 169 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8873 {
8874
4/4
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 89 times.
169 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8875 }
8876
8877 // Run an NSF, or a MIDI if the NSF is missing somehow.
8878 15 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8879 {
8880 15 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8881
8882 // Found it
8883
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(newzcmusic!=NULL)
8884 {
8885 15 zcmusic_stop(zcmusic);
8886 15 zcmusic_unload_file(zcmusic);
8887 15 zc_stop_midi();
8888
8889 15 zcmusic=newzcmusic;
8890 15 zcmusic_play(zcmusic, emusic_volume);
8891
8892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(track>0)
8893 15 zcmusic_change_track(zcmusic,track);
8894
8895 15 return true;
8896 }
8897
8898 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8899 else if(midi>-1000)
8900 jukebox(midi);
8901
8902 return false;
8903 15 }
8904
8905 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8906 {
8907 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8908 // Found it
8909 if(newzcmusic!=NULL)
8910 {
8911 zcmusic_stop(zcmusic);
8912 zcmusic_unload_file(zcmusic);
8913 zc_stop_midi();
8914
8915 zcmusic=newzcmusic;
8916 zcmusic_play(zcmusic, emusic_volume);
8917
8918 if(track>0)
8919 zcmusic_change_track(zcmusic,track);
8920
8921 return true;
8922 }
8923
8924 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8925 else if(midi>-1000)
8926 jukebox(midi);
8927
8928 return false;
8929 }
8930
8931 int32_t get_zcmusicpos()
8932 {
8933 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8934 return debugtracething;
8935 return 0;
8936 }
8937
8938 void set_zcmusicpos(int32_t position)
8939 {
8940 zcmusic_set_curpos(zcmusic, position);
8941 }
8942
8943 void set_zcmusicspeed(int32_t speed)
8944 {
8945 int32_t newspeed = vbound(speed, 0, 10000);
8946 zcmusic_set_speed(zcmusic, newspeed);
8947 }
8948
8949 80 void jukebox(int32_t index,int32_t loop)
8950 {
8951 80 music_stop();
8952
8953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if(index<0) index=MAXMIDIS-1;
8954
8955
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if(index>=MAXMIDIS) index=0;
8956
8957 80 music_stop();
8958
8959 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8960 // stuck notes when a song stops. This fixes it.
8961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if(strcmp(midi_driver->name, "DIGMID")==0)
8962 zc_set_volume(0, 0);
8963
8964 80 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8965 80 zc_play_midi((MIDI*)tunes[index].data,loop);
8966
8967
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 9 times.
80 if(tunes[index].start>0)
8968 9 zc_midi_seek(tunes[index].start);
8969
8970 80 midi_loop_start = tunes[index].loop_start;
8971 80 midi_loop_end = tunes[index].loop_end;
8972
8973 80 currmidi=index;
8974 80 master_volume(digi_volume,midi_volume);
8975 80 midi_paused=false;
8976 80 }
8977
8978 586 void jukebox(int32_t index)
8979 {
8980
1/2
✓ Branch 0 taken 586 times.
✗ Branch 1 not taken.
586 if(index<0) index=MAXMIDIS-1;
8981
8982
1/2
✓ Branch 0 taken 586 times.
✗ Branch 1 not taken.
586 if(index>=MAXMIDIS) index=0;
8983
8984 // do nothing if it's already playing
8985
3/4
✓ Branch 0 taken 506 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 506 times.
✗ Branch 3 not taken.
586 if(index==currmidi && midi_pos>=0)
8986 {
8987 506 midi_paused=false;
8988 506 return;
8989 }
8990
8991 80 jukebox(index,tunes[index].loop);
8992 586 }
8993
8994 1038 void play_DmapMusic()
8995 {
8996 static char tfile[2048];
8997 static int32_t ttrack=0;
8998 1038 bool domidi=false;
8999
9000
2/2
✓ Branch 0 taken 463 times.
✓ Branch 1 taken 575 times.
1038 if(DMaps[currdmap].tmusic[0]!=0)
9001 {
9002
3/4
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 81 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 382 times.
845 if(zcmusic==NULL ||
9003
1/2
✓ Branch 0 taken 382 times.
✗ Branch 1 not taken.
382 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
9004
1/2
✓ Branch 0 taken 382 times.
✗ Branch 1 not taken.
382 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
9005 {
9006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if(zcmusic != NULL)
9007 {
9008 zcmusic_stop(zcmusic);
9009 zcmusic_unload_file(zcmusic);
9010 zcmusic = NULL;
9011 }
9012
9013 81 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
9014
9015
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(zcmusic!=NULL)
9016 {
9017 81 zc_stop_midi();
9018 81 strcpy(tfile,DMaps[currdmap].tmusic);
9019 81 zcmusic_play(zcmusic, emusic_volume);
9020 81 int32_t temptracks=0;
9021 81 temptracks=zcmusic_get_tracks(zcmusic);
9022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 temptracks=(temptracks<2)?1:temptracks;
9023 81 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
9024 81 zcmusic_change_track(zcmusic,ttrack);
9025 81 }
9026 else
9027 {
9028 tfile[0] = 0;
9029 domidi=true;
9030 }
9031 81 }
9032 463 }
9033 else
9034 {
9035 575 domidi=true;
9036 }
9037
9038
2/2
✓ Branch 0 taken 463 times.
✓ Branch 1 taken 575 times.
1038 if(domidi)
9039 {
9040 575 int32_t m=DMaps[currdmap].midi;
9041
9042
3/4
✓ Branch 0 taken 486 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
575 switch(m)
9043 {
9044 case 1:
9045 80 jukebox(ZC_MIDI_OVERWORLD);
9046 80 break;
9047
9048 case 2:
9049 9 jukebox(ZC_MIDI_DUNGEON);
9050 9 break;
9051
9052 case 3:
9053 jukebox(ZC_MIDI_LEVEL9);
9054 break;
9055
9056 default:
9057
3/4
✓ Branch 0 taken 479 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 479 times.
486 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9058 479 jukebox(m+MIDIOFFSET_DMAP);
9059 else
9060 7 music_stop();
9061 486 }
9062 575 }
9063 1038 }
9064
9065 1038 void playLevelMusic()
9066 {
9067 1038 int32_t m=tmpscr->screen_midi;
9068
9069
1/6
✓ Branch 0 taken 1038 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1038 switch(m)
9070 {
9071 case -2:
9072 music_stop();
9073 break;
9074
9075 case -1:
9076 1038 play_DmapMusic();
9077 1038 break;
9078
9079 case 1:
9080 jukebox(ZC_MIDI_OVERWORLD);
9081 break;
9082
9083 case 2:
9084 jukebox(ZC_MIDI_DUNGEON);
9085 break;
9086
9087 case 3:
9088 jukebox(ZC_MIDI_LEVEL9);
9089 break;
9090
9091 default:
9092 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9093 jukebox(m+MIDIOFFSET_MAPSCR);
9094 else
9095 music_stop();
9096 }
9097 1038 }
9098
9099 89 void master_volume(int32_t dv,int32_t mv)
9100 {
9101
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 89 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 89 times.
✗ Branch 7 not taken.
89 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
9102
9103
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89 times.
✓ Branch 4 taken 89 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 89 times.
89 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
9104
9105
5/6
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 78 times.
✓ Branch 5 taken 11 times.
89 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
9106 89 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
9107 89 }
9108
9109 /*****************/
9110 /***** SFX *****/
9111 /*****************/
9112
9113 // array of voices, one for each sfx sample in the data file
9114 // 0+ = voice #
9115 // -1 = voice not allocated
9116 9 void Z_init_sound()
9117 {
9118
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<WAV_COUNT; i++)
9119 2304 sfx_voice[i]=-1;
9120
9121
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 9 times.
72 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
9122 63 tunes[i].data = (MIDI*)mididata[i].dat;
9123
9124
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 9 times.
2277 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
9125 2268 tunes[ZC_MIDI_COUNT+j].data=NULL;
9126
9127 9 master_volume(digi_volume,midi_volume);
9128 9 }
9129
9130 // returns number of voices currently allocated
9131 int32_t sfx_count()
9132 {
9133 int32_t c=0;
9134
9135 for(int32_t i=0; i<WAV_COUNT; i++)
9136 if(sfx_voice[i]!=-1)
9137 ++c;
9138
9139 return c;
9140 }
9141
9142 // clean up finished samples
9143 697240 void sfx_cleanup()
9144 {
9145
2/2
✓ Branch 0 taken 178493440 times.
✓ Branch 1 taken 697240 times.
179190680 for(int32_t i=0; i<WAV_COUNT; i++)
9146
4/4
✓ Branch 0 taken 2538157 times.
✓ Branch 1 taken 175955283 times.
✓ Branch 2 taken 2533634 times.
✓ Branch 3 taken 4523 times.
178497963 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
9147 {
9148 4523 deallocate_voice(sfx_voice[i]);
9149 4523 sfx_voice[i]=-1;
9150 4523 }
9151 697240 }
9152
9153 // allocates a voice for the sample "wav_index" (index into zelda.dat)
9154 // if a voice is already allocated (and/or playing), then it just returns true
9155 // Returns true: voice is allocated
9156 // false: unsuccessful
9157 88487 bool sfx_init(int32_t index)
9158 {
9159 // check index
9160
3/4
✓ Branch 0 taken 83148 times.
✓ Branch 1 taken 5339 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 83148 times.
88487 if(index<=0 || index>=WAV_COUNT)
9161 5339 return false;
9162
9163
2/2
✓ Branch 0 taken 76836 times.
✓ Branch 1 taken 6312 times.
83148 if(sfx_voice[index]==-1)
9164 {
9165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6312 times.
6312 if(sfxdat)
9166 {
9167 if(index<Z35)
9168 {
9169 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
9170 }
9171 else
9172 {
9173 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
9174 }
9175 }
9176 else
9177 {
9178 6312 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
9179 }
9180
9181 6312 voice_set_volume(sfx_voice[index], sfx_volume);
9182 6312 }
9183
9184 83148 return sfx_voice[index] != -1;
9185 88487 }
9186
9187 // plays an sfx sample
9188 63855 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
9189 {
9190
2/2
✓ Branch 0 taken 61000 times.
✓ Branch 1 taken 2855 times.
63855 if(!sfx_init(index))
9191 2855 return;
9192
9193 61000 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9194 61000 voice_set_pan(sfx_voice[index],pan);
9195
9196 61000 int32_t pos = voice_get_position(sfx_voice[index]);
9197
9198
2/2
✓ Branch 0 taken 31344 times.
✓ Branch 1 taken 29656 times.
61000 if(restart) voice_set_position(sfx_voice[index],0);
9199
9200
2/2
✓ Branch 0 taken 33453 times.
✓ Branch 1 taken 27547 times.
61000 if(pos<=0)
9201 33453 voice_start(sfx_voice[index]);
9202 63855 }
9203
9204 // true if sfx is allocated
9205 1 bool sfx_allocated(int32_t index)
9206 {
9207
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
9208 }
9209
9210 // start it (in loop mode) if it's not already playing,
9211 // otherwise adjust it to play in loop mode -DD
9212 24632 void cont_sfx(int32_t index)
9213 {
9214
2/2
✓ Branch 0 taken 2484 times.
✓ Branch 1 taken 22148 times.
24632 if(!sfx_init(index))
9215 {
9216 2484 return;
9217 }
9218
9219
2/2
✓ Branch 0 taken 1170 times.
✓ Branch 1 taken 20978 times.
22148 if(voice_get_position(sfx_voice[index])<=0)
9220 {
9221 1170 voice_set_position(sfx_voice[index],0);
9222 1170 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
9223 1170 voice_start(sfx_voice[index]);
9224 1170 }
9225 else
9226 {
9227 20978 adjust_sfx(index, 128, true);
9228 }
9229 24632 }
9230
9231 // adjust parameters while playing
9232 21346 void adjust_sfx(int32_t index,int32_t pan,bool loop)
9233 {
9234
5/6
✓ Branch 0 taken 21062 times.
✓ Branch 1 taken 284 times.
✓ Branch 2 taken 21062 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21000 times.
✓ Branch 5 taken 62 times.
21346 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
9235 346 return;
9236
9237 21000 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9238 21000 voice_set_pan(sfx_voice[index],pan);
9239 21346 }
9240
9241 // pauses a voice
9242 33 void pause_sfx(int32_t index)
9243 {
9244
3/6
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 33 times.
33 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9245 voice_stop(sfx_voice[index]);
9246 33 }
9247
9248 // resumes a voice
9249 16 void resume_sfx(int32_t index)
9250 {
9251
3/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
16 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9252 voice_start(sfx_voice[index]);
9253 16 }
9254
9255 // pauses all active voices
9256 1 void pause_all_sfx()
9257 {
9258
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for(int32_t i=0; i<WAV_COUNT; i++)
9259
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 2 times.
258 if(sfx_voice[i]!=-1)
9260 2 voice_stop(sfx_voice[i]);
9261 1 }
9262
9263 // resumes all paused voices
9264 void resume_all_sfx()
9265 {
9266 for(int32_t i=0; i<WAV_COUNT; i++)
9267 if(sfx_voice[i]!=-1)
9268 voice_start(sfx_voice[i]);
9269 }
9270
9271 // stops an sfx and deallocates the voice
9272 543718 void stop_sfx(int32_t index)
9273 {
9274
3/4
✓ Branch 0 taken 542291 times.
✓ Branch 1 taken 1427 times.
✓ Branch 2 taken 542291 times.
✗ Branch 3 not taken.
543718 if(index<=0 || index>=WAV_COUNT)
9275 1427 return;
9276
9277
2/2
✓ Branch 0 taken 1386 times.
✓ Branch 1 taken 540905 times.
542291 if(sfx_voice[index]!=-1)
9278 {
9279 1386 deallocate_voice(sfx_voice[index]);
9280 1386 sfx_voice[index]=-1;
9281 1386 }
9282 543718 }
9283
9284 // Stops SFX played by Hero's item of the given family
9285 4213 void stop_item_sfx(int32_t family)
9286 {
9287 4213 int32_t id=current_item_id(family);
9288
9289
2/2
✓ Branch 0 taken 4167 times.
✓ Branch 1 taken 46 times.
4213 if(id<0)
9290 4167 return;
9291
9292 46 stop_sfx(itemsbuf[id].usesound);
9293 4213 }
9294
9295 174 void kill_sfx()
9296 {
9297
2/2
✓ Branch 0 taken 44544 times.
✓ Branch 1 taken 174 times.
44718 for(int32_t i=0; i<WAV_COUNT; i++)
9298
2/2
✓ Branch 0 taken 44156 times.
✓ Branch 1 taken 388 times.
44932 if(sfx_voice[i]!=-1)
9299 {
9300 388 deallocate_voice(sfx_voice[i]);
9301 388 sfx_voice[i]=-1;
9302 388 }
9303 174 }
9304
9305 58173 int32_t pan(int32_t x)
9306 {
9307
1/4
✓ Branch 0 taken 58173 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58173 switch(pan_style)
9308 {
9309 case 0:
9310 return 128;
9311
9312 case 1:
9313 58173 return vbound((x>>1)+68,0,255);
9314
9315 case 2:
9316 return vbound(((x*3)>>2)+36,0,255);
9317 }
9318
9319 return vbound(x,0,255);
9320 58173 }
9321
9322 /*******************************/
9323 /******* Input Handlers ********/
9324 /*******************************/
9325
9326 1044926 bool joybtn(int32_t b)
9327 {
9328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1044926 times.
1044926 if(b == 0)
9329 return false;
9330
9331 1044926 return joy[joystick_index].button[b-1].b !=0;
9332 1044926 }
9333
9334 const char* joybtn_name(int32_t b)
9335 {
9336 if(b == 0)
9337 return "";
9338
9339 return joy[joystick_index].button[b-1].name;
9340 }
9341
9342 int32_t next_press_key()
9343 {
9344 return readkey()>>8;
9345 }
9346
9347 int32_t next_press_btn()
9348 {
9349 clear_keybuf();
9350 /*bool b[joy[joystick_index].num_buttons+1];
9351
9352 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9353 b[i]=joybtn(i);*/
9354
9355 //first, we need to wait until they're pressing no buttons
9356 for(;;)
9357 {
9358 if(keypressed())
9359 {
9360 switch(readkey()>>8)
9361 {
9362 case KEY_ESC:
9363 return -1;
9364
9365 case KEY_SPACE:
9366 return 0;
9367 }
9368 }
9369
9370 poll_joystick();
9371 bool done = true;
9372
9373 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9374 {
9375 if(joybtn(i)) done = false;
9376 }
9377
9378 if(done) break;
9379 rest(1);
9380 }
9381
9382 //now, we need to wait for them to press any button
9383 for(;;)
9384 {
9385 if(keypressed())
9386 {
9387 switch(readkey()>>8)
9388 {
9389 case KEY_ESC:
9390 return -1;
9391
9392 case KEY_SPACE:
9393 return 0;
9394 }
9395 }
9396
9397 poll_joystick();
9398
9399 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9400 {
9401 if(joybtn(i)) return i;
9402 }
9403 rest(1);
9404 }
9405 }
9406
9407 static bool rButton(bool(proc)(),bool &flag)
9408 {
9409 if(!proc())
9410 {
9411 flag=false;
9412 }
9413 else if(!flag)
9414 {
9415 flag=true;
9416 return true;
9417 }
9418
9419 return false;
9420 }
9421
9422 13658929 static bool rButton(bool &btn, bool &flag)
9423 {
9424
2/2
✓ Branch 0 taken 548223 times.
✓ Branch 1 taken 13110706 times.
13658929 if(!btn)
9425 {
9426 13110706 flag=false;
9427 13110706 }
9428
2/2
✓ Branch 0 taken 27186 times.
✓ Branch 1 taken 521037 times.
548223 else if(!flag)
9429 {
9430 27186 flag=true;
9431 27186 return true;
9432 }
9433
9434 13631743 return false;
9435 13658929 }
9436 619 static bool rButtonPeek(bool btn, bool flag)
9437 {
9438
2/2
✓ Branch 0 taken 583 times.
✓ Branch 1 taken 36 times.
619 if(!btn)
9439 {
9440 583 return false;
9441 }
9442
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 27 times.
36 else if(!flag)
9443 {
9444 9 return true;
9445 }
9446
9447 27 return false;
9448 619 }
9449
9450 // Updated only by keyboard/gamepad.
9451 // If in replay mode, this is set directly by the replay system.
9452 // This should never be read from directly - use control_state instead.
9453 bool raw_control_state[ZC_CONTROL_STATES]=
9454 {
9455 false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
9456 };
9457
9458 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9459 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9460 // lasts until the next call to load_control_state.
9461 bool control_state[ZC_CONTROL_STATES]=
9462 {
9463 false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
9464 };
9465
9466 bool disable_control[ZC_CONTROL_STATES]=
9467 {
9468 false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
9469 };
9470
9471 bool drunk_toggle_state[11]=
9472 {
9473 false, false, false, false, false, false, false, false, false, false, false
9474 };
9475
9476 bool disabledKeys[127]=
9477 {
9478 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9479 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9480 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9481 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9482 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9483 false,false,false,false,false,false,false
9484 };
9485
9486 bool KeyInput[127]=
9487 {
9488 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9489 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9490 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9491 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9492 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9493 false,false,false,false,false,false,false
9494 };
9495
9496 bool KeyPress[127]=
9497 {
9498 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9499 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9500 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9501 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9502 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9503 false,false,false,false,false,false,false
9504 };
9505
9506 bool key_current_frame[127];
9507 bool key_previous_frame[127];
9508
9509 static bool key_system[127];
9510 static bool key_system_previous[127];
9511 static bool key_system_press[127];
9512
9513 bool button_press[ZC_CONTROL_STATES] = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
9514 bool button_hold[ZC_CONTROL_STATES] = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
9515
9516 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9517 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9518 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9519 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9520 #define STICK_PRECISION 56 //define your own sensitivity
9521
9522 548157 void load_control_state()
9523 {
9524
1/2
✓ Branch 0 taken 548157 times.
✗ Branch 1 not taken.
548157 if (!replay_is_replaying())
9525 {
9526 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9527 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9528 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9529 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9530 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9531 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9532 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9533 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9534 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9535 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9536 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9537 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9538 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9539 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9540
9541 if(num_joysticks != 0)
9542 {
9543 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9544 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9545 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9546 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9547 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9548 }
9549 else
9550 {
9551 raw_control_state[14] = false;
9552 raw_control_state[15] = false;
9553 raw_control_state[16] = false;
9554 raw_control_state[17] = false;
9555 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9556 }
9557 }
9558
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 548154 times.
548157 if (replay_is_active())
9559 {
9560
2/2
✓ Branch 0 taken 510132 times.
✓ Branch 1 taken 38022 times.
548154 if (replay_get_version() < 3)
9561 510132 replay_poll();
9562
3/4
✓ Branch 0 taken 38022 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9443 times.
✓ Branch 3 taken 28579 times.
38022 else if (replay_is_replaying() && replay_get_version() < 6)
9563 28579 replay_peek_input();
9564 548154 }
9565
9566 // Some test replay files were made before a serious input bug was fixed, so instead
9567 // of re-doing them or tossing them out, just check for that zplay version.
9568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 548151 times.
548157 bool botched_input = replay_is_replaying() && replay_get_version() == 1;
9569
2/2
✓ Branch 0 taken 548151 times.
✓ Branch 1 taken 9866718 times.
10414869 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9570 {
9571 9866718 control_state[i] = raw_control_state[i];
9572
4/4
✓ Branch 0 taken 7672518 times.
✓ Branch 1 taken 2194200 times.
✓ Branch 2 taken 415575 times.
✓ Branch 3 taken 7256943 times.
9866718 if(!botched_input && !control_state[i])
9573 7256943 down_control_states[i] = false;
9574 9866718 }
9575
9576 548151 button_press[0]=rButton(control_state[0],button_hold[0]);
9577 548151 button_press[1]=rButton(control_state[1],button_hold[1]);
9578 548151 button_press[2]=rButton(control_state[2],button_hold[2]);
9579 548151 button_press[3]=rButton(control_state[3],button_hold[3]);
9580 548151 button_press[4]=rButton(control_state[4],button_hold[4]);
9581 548151 button_press[5]=rButton(control_state[5],button_hold[5]);
9582 548151 button_press[6]=rButton(control_state[6],button_hold[6]);
9583 548151 button_press[7]=rButton(control_state[7],button_hold[7]);
9584 548151 button_press[8]=rButton(control_state[8],button_hold[8]);
9585 548151 button_press[9]=rButton(control_state[9],button_hold[9]);
9586 548151 button_press[10]=rButton(control_state[10],button_hold[10]);
9587 548151 button_press[11]=rButton(control_state[11],button_hold[11]);
9588 548151 button_press[12]=rButton(control_state[12],button_hold[12]);
9589 548151 button_press[13]=rButton(control_state[13],button_hold[13]);
9590 548151 button_press[14]=rButton(control_state[14],button_hold[14]);
9591 548151 button_press[15]=rButton(control_state[15],button_hold[15]);
9592 548151 button_press[16]=rButton(control_state[16],button_hold[16]);
9593 548151 button_press[17]=rButton(control_state[17],button_hold[17]);
9594 548151 }
9595
9596 // Returns true if any game key is pressed. This is needed because keypressed()
9597 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9598 2464814 bool zc_key_pressed()
9599 //may also need to use zc_getrawkey
9600 {
9601
7/10
✓ Branch 0 taken 1923459 times.
✓ Branch 1 taken 541355 times.
✓ Branch 2 taken 541355 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 541355 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 451578 times.
✓ Branch 7 taken 451578 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 102888 times.
2567702 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9602
4/6
✓ Branch 0 taken 451578 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 451578 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 316612 times.
✓ Branch 5 taken 316612 times.
451578 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9603
4/6
✓ Branch 0 taken 316612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 316612 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162034 times.
✓ Branch 5 taken 162034 times.
316612 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9604
4/6
✓ Branch 0 taken 162034 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162034 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115908 times.
✓ Branch 5 taken 115908 times.
162034 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9605
1/2
✓ Branch 0 taken 115908 times.
✗ Branch 1 not taken.
115908 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9606
3/4
✓ Branch 0 taken 105347 times.
✓ Branch 1 taken 10561 times.
✓ Branch 2 taken 105347 times.
✗ Branch 3 not taken.
115908 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9607
3/4
✓ Branch 0 taken 103313 times.
✓ Branch 1 taken 2034 times.
✓ Branch 2 taken 103313 times.
✗ Branch 3 not taken.
105347 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9608
3/4
✓ Branch 0 taken 103030 times.
✓ Branch 1 taken 283 times.
✓ Branch 2 taken 103030 times.
✗ Branch 3 not taken.
103313 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9609
3/4
✓ Branch 0 taken 102888 times.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 102888 times.
✗ Branch 3 not taken.
103030 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9610
2/4
✓ Branch 0 taken 102888 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102888 times.
✗ Branch 3 not taken.
102888 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9611
2/4
✓ Branch 0 taken 102888 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102888 times.
✗ Branch 3 not taken.
102888 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9612
2/4
✓ Branch 0 taken 102888 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102888 times.
✗ Branch 3 not taken.
102888 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9613
2/4
✓ Branch 0 taken 102888 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102888 times.
✗ Branch 3 not taken.
102888 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9614
1/2
✓ Branch 0 taken 102888 times.
✗ Branch 1 not taken.
102888 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9615 4454190 return true;
9616
9617 102888 return false;
9618 710160 }
9619
9620 11126671 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9621 {
9622 11126671 bool ret = false, drunkstate = false;
9623 11126671 bool* flag = &down_control_states[btn];
9624
2/7
✓ Branch 0 taken 10415571 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 711100 times.
11126671 switch(btn)
9625 {
9626 case btnF12:
9627 ret = zc_getkey(KEY_F12, ignoreDisable);
9628 eatEntirely = false;
9629 break;
9630 case btnF11:
9631 ret = zc_getkey(KEY_F11, ignoreDisable);
9632 eatEntirely = false;
9633 break;
9634 case btnF5:
9635 ret = zc_getkey(KEY_F5, ignoreDisable);
9636 eatEntirely = false;
9637 break;
9638 case btnQ:
9639 ret = zc_getkey(KEY_Q, ignoreDisable);
9640 eatEntirely = false;
9641 break;
9642 case btnI:
9643 ret = zc_getkey(KEY_I, ignoreDisable);
9644 eatEntirely = false;
9645 break;
9646 case btnM:
9647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 711100 times.
711100 if(FFCore.kb_typing_mode) return false;
9648 711100 ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9649 711100 eatEntirely = false;
9650 711100 break;
9651 default: //control_state[] index
9652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10415571 times.
10415571 if(FFCore.kb_typing_mode) return false;
9653
5/6
✓ Branch 0 taken 10401831 times.
✓ Branch 1 taken 13740 times.
✓ Branch 2 taken 237289 times.
✓ Branch 3 taken 10164542 times.
✓ Branch 4 taken 237289 times.
✗ Branch 5 not taken.
10415571 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9654
2/2
✓ Branch 0 taken 550122 times.
✓ Branch 1 taken 9865449 times.
10415571 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9655
4/4
✓ Branch 0 taken 9214384 times.
✓ Branch 1 taken 1201187 times.
✓ Branch 2 taken 290 times.
✓ Branch 3 taken 1200897 times.
11616758 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9656 10415571 }
9657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11126671 times.
11126671 assert(flag);
9658
2/2
✓ Branch 0 taken 7333841 times.
✓ Branch 1 taken 3792830 times.
11126671 if(press)
9659 {
9660
2/2
✓ Branch 0 taken 619 times.
✓ Branch 1 taken 3792211 times.
3792830 if(peek)
9661 619 ret = rButtonPeek(ret, *flag);
9662 3792211 else ret = rButton(ret, *flag);
9663 3792830 }
9664
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11126671 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11126671 if(eatEntirely && ret) control_state[btn] = false;
9665
3/4
✓ Branch 0 taken 8668931 times.
✓ Branch 1 taken 2457740 times.
✓ Branch 2 taken 8668931 times.
✗ Branch 3 not taken.
11126671 if(drunk && drunkstate) ret = !ret;
9666 11126671 return ret;
9667 11126671 }
9668
9669 8056 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9670 {
9671 8056 byte ret = 0;
9672
2/2
✓ Branch 0 taken 7437 times.
✓ Branch 1 taken 619 times.
8056 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9673
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9674
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9675
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9676
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9677
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9678
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9679
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9680 8056 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9681 }
9682
9683 byte checkIntBtnVal(byte intbtn, byte vals)
9684 {
9685 return intbtn&vals;
9686 }
9687
9688 114950 bool Up()
9689 {
9690 114950 return getInput(btnUp);
9691 }
9692 1710 bool Down()
9693 {
9694 1710 return getInput(btnDown);
9695 }
9696 3350 bool Left()
9697 {
9698 3350 return getInput(btnLeft);
9699 }
9700 4012 bool Right()
9701 {
9702 4012 return getInput(btnRight);
9703 }
9704 5873 bool cAbtn()
9705 {
9706 5873 return getInput(btnA);
9707 }
9708 23581 bool cBbtn()
9709 {
9710 23581 return getInput(btnB);
9711 }
9712 bool cSbtn()
9713 {
9714 return getInput(btnS);
9715 }
9716 bool cLbtn()
9717 {
9718 return getInput(btnL);
9719 }
9720 bool cRbtn()
9721 {
9722 return getInput(btnR);
9723 }
9724 bool cPbtn()
9725 {
9726 return getInput(btnP);
9727 }
9728 bool cEx1btn()
9729 {
9730 return getInput(btnEx1);
9731 }
9732 bool cEx2btn()
9733 {
9734 return getInput(btnEx2);
9735 }
9736 bool cEx3btn()
9737 {
9738 return getInput(btnEx3);
9739 }
9740 bool cEx4btn()
9741 {
9742 return getInput(btnEx4);
9743 }
9744 bool AxisUp()
9745 {
9746 return getInput(btnAxisUp);
9747 }
9748 bool AxisDown()
9749 {
9750 return getInput(btnAxisDown);
9751 }
9752 bool AxisLeft()
9753 {
9754 return getInput(btnAxisLeft);
9755 }
9756 bool AxisRight()
9757 {
9758 return getInput(btnAxisRight);
9759 }
9760
9761 bool cMbtn()
9762 {
9763 return getInput(btnM);
9764 }
9765 bool cF12()
9766 {
9767 return getInput(btnF12);
9768 }
9769 bool cF11()
9770 {
9771 return getInput(btnF11);
9772 }
9773 bool cF5()
9774 {
9775 return getInput(btnF5);
9776 }
9777 bool cQ()
9778 {
9779 return getInput(btnQ);
9780 }
9781 bool cI()
9782 {
9783 return getInput(btnI);
9784 }
9785
9786 872 bool rUp()
9787 {
9788 872 return getInput(btnUp, true);
9789 }
9790 862 bool rDown()
9791 {
9792 862 return getInput(btnDown, true);
9793 }
9794 861 bool rLeft()
9795 {
9796 861 return getInput(btnLeft, true);
9797 }
9798 860 bool rRight()
9799 {
9800 860 return getInput(btnRight, true);
9801 }
9802 53 bool rAbtn()
9803 {
9804 53 return getInput(btnA, true);
9805 }
9806 925 bool rBbtn()
9807 {
9808 925 return getInput(btnB, true);
9809 }
9810 546696 bool rSbtn()
9811 {
9812 546696 return getInput(btnS, true);
9813 }
9814 710160 bool rMbtn()
9815 {
9816 710160 return getInput(btnM, true);
9817 }
9818 859 bool rLbtn()
9819 {
9820 859 return getInput(btnL, true);
9821 }
9822 859 bool rRbtn()
9823 {
9824 859 return getInput(btnR, true);
9825 }
9826 545590 bool rPbtn()
9827 {
9828 545590 return getInput(btnP, true);
9829 }
9830 bool rEx1btn()
9831 {
9832 return getInput(btnEx1, true);
9833 }
9834 bool rEx2btn()
9835 {
9836 return getInput(btnEx2, true);
9837 }
9838 859 bool rEx3btn()
9839 {
9840 859 return getInput(btnEx3, true);
9841 }
9842 859 bool rEx4btn()
9843 {
9844 859 return getInput(btnEx4, true);
9845 }
9846 bool rAxisUp()
9847 {
9848 return getInput(btnAxisUp, true);
9849 }
9850 bool rAxisDown()
9851 {
9852 return getInput(btnAxisDown, true);
9853 }
9854 bool rAxisLeft()
9855 {
9856 return getInput(btnAxisLeft, true);
9857 }
9858 bool rAxisRight()
9859 {
9860 return getInput(btnAxisRight, true);
9861 }
9862
9863 bool rF11()
9864 {
9865 return getInput(btnF11, true);
9866 }
9867 bool rQ()
9868 {
9869 return getInput(btnQ, true);
9870 }
9871 bool rI()
9872 {
9873 return getInput(btnI, true);
9874 }
9875
9876 1450647 bool DrunkUp()
9877 {
9878 1450647 return getInput(btnUp, false, true);
9879 }
9880 1340373 bool DrunkDown()
9881 {
9882 1340373 return getInput(btnDown, false, true);
9883 }
9884 877941 bool DrunkLeft()
9885 {
9886 877941 return getInput(btnLeft, false, true);
9887 }
9888 766561 bool DrunkRight()
9889 {
9890 766561 return getInput(btnRight, false, true);
9891 }
9892 628238 bool DrunkcAbtn()
9893 {
9894 628238 return getInput(btnA, false, true);
9895 }
9896 546168 bool DrunkcBbtn()
9897 {
9898 546168 return getInput(btnB, false, true);
9899 }
9900 545584 bool DrunkcEx1btn()
9901 {
9902 545584 return getInput(btnEx1, false, true);
9903 }
9904 545584 bool DrunkcEx2btn()
9905 {
9906 545584 return getInput(btnEx2, false, true);
9907 }
9908 bool DrunkcSbtn()
9909 {
9910 return getInput(btnS, false, true);
9911 }
9912 bool DrunkcMbtn()
9913 {
9914 return getInput(btnM, false, true);
9915 }
9916 bool DrunkcLbtn()
9917 {
9918 return getInput(btnL, false, true);
9919 }
9920 bool DrunkcRbtn()
9921 {
9922 return getInput(btnR, false, true);
9923 }
9924 bool DrunkcPbtn()
9925 {
9926 return getInput(btnP, false, true);
9927 }
9928
9929 bool DrunkrUp()
9930 {
9931 return getInput(btnUp, true, true);
9932 }
9933 bool DrunkrDown()
9934 {
9935 return getInput(btnDown, true, true);
9936 }
9937 bool DrunkrLeft()
9938 {
9939 return getInput(btnLeft, true, true);
9940 }
9941 bool DrunkrRight()
9942 {
9943 return getInput(btnRight, true, true);
9944 }
9945 437382 bool DrunkrAbtn()
9946 {
9947 437382 return getInput(btnA, true, true);
9948 }
9949 438817 bool DrunkrBbtn()
9950 {
9951 438817 return getInput(btnB, true, true);
9952 }
9953 bool DrunkrEx1btn()
9954 {
9955 return getInput(btnEx1, true, true);
9956 }
9957 bool DrunkrEx2btn()
9958 {
9959 return getInput(btnEx2, true, true);
9960 }
9961 bool DrunkrEx3btn()
9962 {
9963 return getInput(btnEx3, true, true);
9964 }
9965 bool DrunkrEx4btn()
9966 {
9967 return getInput(btnEx4, true, true);
9968 }
9969 bool DrunkrSbtn()
9970 {
9971 return getInput(btnS, true, true);
9972 }
9973 bool DrunkrMbtn()
9974 {
9975 return getInput(btnM, true, true);
9976 }
9977 545590 bool DrunkrLbtn()
9978 {
9979 545590 return getInput(btnL, true, true);
9980 }
9981 545427 bool DrunkrRbtn()
9982 {
9983 545427 return getInput(btnR, true, true);
9984 }
9985 bool DrunkrPbtn()
9986 {
9987 return getInput(btnP, true, true);
9988 }
9989
9990 940 void eat_buttons()
9991 {
9992 940 getInput(btnA, true, false, true);
9993 940 getInput(btnB, true, false, true);
9994 940 getInput(btnS, true, false, true);
9995 940 getInput(btnM, true, false, true);
9996 940 getInput(btnL, true, false, true);
9997 940 getInput(btnR, true, false, true);
9998 940 getInput(btnP, true, false, true);
9999 940 getInput(btnEx1, true, false, true);
10000 940 getInput(btnEx2, true, false, true);
10001 940 getInput(btnEx3, true, false, true);
10002 940 getInput(btnEx4, true, false, true);
10003 940 }
10004
10005 // Is true for the _first frame_ of a key press.
10006 // But! it is possible that a script manually sets the value of KeyPress,
10007 // in which case it will be restored to the "true" value based on `key_current_frame`
10008 // and `key_previous_frame` on the next frame.
10009 1 bool zc_readkey(int32_t k, bool ignoreDisable)
10010 {
10011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(ignoreDisable) return KeyPress[k];
10012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 switch(k)
10013 {
10014 case KEY_F7:
10015 case KEY_F8:
10016 case KEY_F9:
10017 return KeyPress[k];
10018
10019 default:
10020
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 return KeyPress[k] && !disabledKeys[k];
10021 }
10022 1 }
10023
10024 // Is true for _every frame_ a key is held down.
10025 // But! it is possible that a script manually sets the value of KeyInput,
10026 // in which case it will be restored to the "true" value based on `key_current_frame`
10027 // on the next frame.
10028 bool zc_getkey(int32_t k, bool ignoreDisable)
10029 {
10030 if(ignoreDisable) return KeyInput[k];
10031 switch(k)
10032 {
10033 case KEY_F7:
10034 case KEY_F8:
10035 case KEY_F9:
10036 return KeyInput[k];
10037
10038 default:
10039 return KeyInput[k] && !disabledKeys[k];
10040 }
10041 }
10042
10043 // Reads (and then clears) the current frame key state directly.
10044 // Scripts can also modify `key_current_frame`.
10045 124831 bool zc_readrawkey(int32_t k, bool ignoreDisable)
10046 {
10047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124831 times.
124831 if(zc_getrawkey(k, ignoreDisable))
10048 {
10049 _key[k]=key[k]=key_current_frame[k]=0;
10050 return true;
10051 }
10052 124831 _key[k]=key[k]=key_current_frame[k]=0;
10053 124831 return false;
10054 124831 }
10055
10056 // Reads the current frame key state directly.
10057 // Scripts can also modify `key_current_frame`.
10058 3959708 bool zc_getrawkey(int32_t k, bool ignoreDisable)
10059 {
10060
2/2
✓ Branch 0 taken 3124718 times.
✓ Branch 1 taken 834990 times.
3959708 if(ignoreDisable) return key_current_frame[k];
10061
2/2
✓ Branch 0 taken 124828 times.
✓ Branch 1 taken 710162 times.
834990 switch(k)
10062 {
10063 case KEY_F7:
10064 case KEY_F8:
10065 case KEY_F9:
10066 124828 return key_current_frame[k];
10067
10068 default:
10069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 710162 times.
710162 return key_current_frame[k] && !disabledKeys[k];
10070 }
10071 3959708 }
10072
10073 // Only used for a handful of keys, like tilde and Function keys.
10074 // This state is never read within the game.
10075 // It exists so that all keyboard input still functions during replay,
10076 // without inadvertently doing things like toggling throttling if the player
10077 // presses ~
10078 697240 bool zc_get_system_key(int32_t k)
10079 {
10080 697240 return key_system[k];
10081 }
10082
10083 // True for the _first_ frame of a key press.
10084 7811760 bool zc_read_system_key(int32_t k)
10085 {
10086 7811760 return key_system_press[k];
10087 }
10088
10089 90190320 bool is_system_key(int32_t k)
10090 {
10091
2/2
✓ Branch 0 taken 83798880 times.
✓ Branch 1 taken 6391440 times.
90190320 switch (k)
10092 {
10093 case KEY_BACKQUOTE:
10094 case KEY_CLOSEBRACE:
10095 case KEY_END:
10096 case KEY_HOME:
10097 case KEY_OPENBRACE:
10098 case KEY_PGDN:
10099 case KEY_PGUP:
10100 case KEY_TAB:
10101 case KEY_TILDE:
10102 6391440 return true;
10103 }
10104 83798880 return is_Fkey(k);
10105 90190320 }
10106
10107 710160 void update_system_keys()
10108 {
10109 710160 poll_keyboard();
10110
2/2
✓ Branch 0 taken 90190320 times.
✓ Branch 1 taken 710160 times.
90900480 for (int32_t q = 0; q < 127; ++q)
10111 {
10112
2/2
✓ Branch 0 taken 14913360 times.
✓ Branch 1 taken 75276960 times.
90190320 if (!is_system_key(q))
10113 75276960 continue;
10114
10115 14913360 key_system[q] = key[q];
10116
1/2
✓ Branch 0 taken 14913360 times.
✗ Branch 1 not taken.
14913360 key_system_press[q] = key_system[q] && !key_system_previous[q];
10117 14913360 key_system_previous[q] = key_system[q];
10118 14913360 }
10119 710160 }
10120
10121 697240 void update_keys()
10122 {
10123
1/2
✓ Branch 0 taken 697240 times.
✗ Branch 1 not taken.
697240 if (!replay_is_replaying())
10124 poll_keyboard();
10125
10126
2/2
✓ Branch 0 taken 697240 times.
✓ Branch 1 taken 88549480 times.
89246720 for (int32_t q = 0; q < 127; ++q)
10127 {
10128 // When replaying, replay.cpp takes care of updating `key_current_frame`.
10129
1/2
✓ Branch 0 taken 88549480 times.
✗ Branch 1 not taken.
88549480 if (!replay_is_replaying())
10130 key_current_frame[q] = key[q];
10131
10132
2/2
✓ Branch 0 taken 87869076 times.
✓ Branch 1 taken 680404 times.
88549480 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
10133
3/4
✓ Branch 0 taken 20628 times.
✓ Branch 1 taken 88528852 times.
✓ Branch 2 taken 20628 times.
✗ Branch 3 not taken.
88549480 if (KeyPress[q] && q == KEY_B) {
10134 int lol = 1;
10135 }
10136 88549480 KeyInput[q] = key_current_frame[q];
10137 88549480 key_previous_frame[q] = key_current_frame[q];
10138 88549480 }
10139 697240 }
10140
10141 bool zc_disablekey(int32_t k, bool val)
10142 {
10143 switch(k)
10144 {
10145 case KEY_F7:
10146 case KEY_F8:
10147 case KEY_F9:
10148 return false;
10149
10150 default:
10151 disabledKeys[k] = val;
10152 return true;
10153 }
10154 }
10155
10156 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
10157 {
10158 timer=timer;
10159 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
10160 }
10161
10162 // these are here so that copy_dialog won't choke when compiling zelda
10163 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
10164 {
10165 return D_O_K;
10166 }
10167
10168 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
10169 {
10170 return D_O_K;
10171 }
10172
10173 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
10174 {
10175 return D_O_K;
10176 }
10177
10178 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
10179 {
10180 return D_O_K;
10181 }
10182
10183 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
10184 {
10185 return D_O_K;
10186 }
10187
10188 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
10189 {
10190 return D_O_K;
10191 }
10192
10193 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
10194 {
10195 return D_O_K;
10196 }
10197
10198 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
10199 {
10200 return D_O_K;
10201 }
10202
10203 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
10204 {
10205 return D_O_K;
10206 }
10207
10208 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
10209 {
10210 return D_O_K;
10211 }
10212
10213 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
10214 {
10215 return D_O_K;
10216 }
10217
10218 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
10219 {
10220 return D_O_K;
10221 }
10222
10223 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
10224 {
10225 return D_O_K;
10226 }
10227
10228 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
10229 {
10230 return D_O_K;
10231 }
10232
10233 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
10234 {
10235 return D_O_K;
10236 }
10237
10238 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
10239 {
10240 return D_O_K;
10241 }
10242
10243 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
10244 {
10245 return D_O_K;
10246 }
10247
10248 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
10249 {
10250 return D_O_K;
10251 }
10252
10253 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
10254 {
10255 return D_O_K;
10256 }
10257
10258 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
10259 {
10260 return D_O_K;
10261 }
10262
10263 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
10264 {
10265 return D_O_K;
10266 }
10267
10268 /*** end of zc_sys.cc ***/
10269
10270